Kys3r Kys3r - 1 year ago 86
Python Question

How to see all variable on interpreter python? (what is the command?)

Is there a command to see all the variables I've defined?


toto = 1
tutu = 2
tata = 3

Suppose I remember I have toto, but I forget the others' declarations (tutu and tata). Is there a command to print all my variables?

Answer Source

You may use globals() to view all the variables/functions accessible in your current file as:

>>> toto = 1
>>> tutu = 2
>>> tata = 3
>>> globals()
     '__builtins__': <module '__builtin__' (built-in)>, 
     'tata': 3, 
     'toto': 1, 
     '__package__': None, 
     '__name__': '__main__', 
     'tutu': 2, 
     '__doc__': None
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download