<table cellspacing="0" cellpadding="0" border="0" ><tr><td valign="top" style="font: inherit;">This may also be useful:<br><br>>>> a = 1<br>>>> b = 2<br>>>> c = 3<br>>>> locals()<br>{'a': 1, 'c': 3, 'b': 2, '__builtins__': <module '__builtin__' (built-in)>, '__name__': '__main__', '__doc__': None}<br>>>> locals().keys()<br>['a', 'c', 'b', '__builtins__', '__name__', '__doc__']<br>>>> <br><br>Cheers!!<br>
Albert-Jan<br>
<br>
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~<br>
In the face of ambiguity, refuse the temptation to guess.<br>
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~<br><br>--- On <b>Fri, 12/25/09, Lie Ryan <i><lie.1296@gmail.com></i></b> wrote:<br><blockquote style="border-left: 2px solid rgb(16, 16, 255); margin-left: 5px; padding-left: 5px;"><br>From: Lie Ryan <lie.1296@gmail.com><br>Subject: Re: [Tutor] Listing available variables<br>To: tutor@python.org<br>Date: Friday, December 25, 2009, 9:16 AM<br><br><div class="plainMail">On 12/25/2009 6:50 PM, Mkhanyisi Madlavana wrote:<br>> How do I list all the available variables in python. for example if I say:<br>>>>> a = range(10)<br>>>>> b = 16<br>>>>> c = ""<br>> .... (some variables)<br>>>>> z = ["this","that","none"]<br>> I then need a command that will list the variables I assigned like:<br>>>>> some_command<br>> a, b, c, ... (some variables), z<br><br>dir()<br><br>>>> a = range(10)<br>>>> b =
16<br>>>> c = ""<br>>>> z = ["this","that","none"]<br>>>> dir()<br>['__builtins__', '__doc__', '__name__', '__package__', 'a', 'b', 'c', 'z']<br><br>_______________________________________________<br>Tutor maillist - <a ymailto="mailto:Tutor@python.org" href="/mc/compose?to=Tutor@python.org">Tutor@python.org</a><br>To unsubscribe or change subscription options:<br><a href="http://mail.python.org/mailman/listinfo/tutor" target="_blank">http://mail.python.org/mailman/listinfo/tutor</a><br></div></blockquote></td></tr></table><br>