Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can PyCharm display variable value as hexadecimal number?

I'm debugging a python script in PyCharm and can't find a way to display integer values as hexadecimal numbers. Is it at all possible in this IDE?

like image 217
Joanna Kowal Avatar asked Oct 16 '19 19:10

Joanna Kowal


People also ask

How do you assign a hex value to a variable in Python?

To assign value in hexadecimal format to a variable, we use 0x or 0X suffix. It tells to the compiler that the value (suffixed with 0x or 0X) is a hexadecimal value and assigns it to the variable.

Can you view variables in PyCharm?

PyCharm allows you to inspect variables in a dedicated dialog. This is useful when you need to keep track of some variable (or the object whose reference it holds) and at the same time be able to navigate between frames and threads. Right-click a variable on the Variables tab and select Inspect.

How does PyCharm determine type of variable?

The only reliable way to know what type a given object is is to inspect it at runtime - which is usually done using a step debugger (either python's builtin pdb or PyCharm's own debugger). Note that you'll have to check the various code path that can lead to the portion of the code you want to inspect though.

What are variables in PyCharm?

Variables Last modified: 27 July 2022. The Variables pane enables you to examine the values stored in the objects of your application.


3 Answers

This feature (for PyCharm) is implemented and is going to be included in 2019.3 release. Ticket https://youtrack.jetbrains.com/issue/PY-8118


Update 2019.3.4

enter image description here

like image 116
Pavel Karateev Avatar answered Oct 16 '22 09:10

Pavel Karateev


As @ndclt pointed out, you can't yet, but a workaround for the time being could be using the evaluate expression functionality.

Say you are interested in the hex representation of a, you can use the built-in function hex() to achieve this:

hex(a)

Putting this in the evaluate expression dialog would give you the hex representation string.

You can bring up that action using CTRL+F8 (Windows/Linux) or ALT+F8 (Mac).

like image 2
bgse Avatar answered Oct 16 '22 08:10

bgse


Yet, you can't. There is an open issue also concerning Pycharm if you want to follow this feature.

like image 1
ndclt Avatar answered Oct 16 '22 07:10

ndclt