[Tutor] Listing available variables

Lie Ryan lie.1296 at gmail.com
Fri Dec 25 09:16:36 CET 2009


On 12/25/2009 6:50 PM, Mkhanyisi Madlavana wrote:
> How do I list all the available variables in python. for example if I say:
>>>> a = range(10)
>>>> b = 16
>>>> c = ""
> .... (some variables)
>>>> z = ["this","that","none"]
> I then need a command that will list the variables I assigned like:
>>>> some_command
> a, b, c, ... (some variables), z

dir()

 >>> a = range(10)
 >>> b = 16
 >>> c = ""
 >>> z = ["this","that","none"]
 >>> dir()
['__builtins__', '__doc__', '__name__', '__package__', 'a', 'b', 'c', 'z']



More information about the Tutor mailing list