In Chrome development console one can type name of a variable and output is a visual and interactive representation of the object. (In JavaScript objects are like dictionaries, so this is easy.)
I would like to have the same functionality in Python. I am shocked I cannot find anything similar. For example in IPython GUI console when I want to inspect variable diff
, I get in this case its type instead:
In [5]: diff
Out[5]: <_pygit2.Diff at 0x1a69930>
This command inspect the variable, but output is chaotic for complicated objects (here the output is incomplete):
In [10]: inspect.getmembers(diff)
Out[10]: [('__class__', <type '_pygit2.Diff'>), ('__delattr__', <method-wrapper '__delattr__' of _pygit2.Diff object at 0x1a69930>), ('__doc__', 'Diff objects.'), ('__format__', <built-in method __format__ of _pygit2.Diff object at 0x1a69930>), ('__getattribute__', (...)
I think a live introspection is very useful when language has no typesystem. Maybe this functionality is available only in special Python IDEs?
To show how it is done in Chrome:
On the picture you can see an introspecion of variable f
. It is an object of type Form
, you can click on it and see its properties (e.g. _meetingTimeFrom
) and theirs values, you can click further on properties to inspect them, you can see object's methods (e.g. field __proto__
, this might be a way how to see object methods in JavaScript).