With gdb
, we can see the memory units, like (gdb) x /**xb address
, helping us understand how the variable reserved in computer actually.
So can i do that with pdb
? and how?
Asked
Active
Viewed 72 times
0

MMMMMCCLXXVII
- 571
- 1
- 8
- 23
1 Answers
1
The answer is No.
pdb has no such option to do this.('variable' called 'reference' may be better).
The variable in python is different from C/C++, For example:
the integer 1, in C his storage form:
0000 0000 0000 0001
However, in python, 1 is not a pure number, It's a structure.
If you look at Python-2.7.13\Include\intobject.h
you will see this:
typedef struct {
PyObject_HEAD
long ob_ival;
} PyIntObject;
I do not think there is a need to look at the storage form of a variable in python.
Sometimes we just need to know what a varible is.
In this situation, you can use 'p'
or 'pp'
.
Doc in https://docs.python.org/2/library/pdb.html.
p expression
Evaluate the expression in the current context and print its value.
pp expression
Like the p command, except the value of the expression is pretty-printed using the pprint module.