<table cellspacing="0" cellpadding="0" border="0" ><tr><td valign="top" style="font: inherit;">This may also be useful:<br><br>&gt;&gt;&gt; a = 1<br>&gt;&gt;&gt; b = 2<br>&gt;&gt;&gt; c = 3<br>&gt;&gt;&gt; locals()<br>{'a': 1, 'c': 3, 'b': 2, '__builtins__': &lt;module '__builtin__' (built-in)&gt;, '__name__': '__main__', '__doc__': None}<br>&gt;&gt;&gt; locals().keys()<br>['a', 'c', 'b', '__builtins__', '__name__', '__doc__']<br>&gt;&gt;&gt; <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>&lt;lie.1296@gmail.com&gt;</i></b> wrote:<br><blockquote style="border-left: 2px solid rgb(16, 16, 255); margin-left: 5px; padding-left: 5px;"><br>From: Lie Ryan &lt;lie.1296@gmail.com&gt;<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>&gt; How do I list all the available variables in python. for example if I say:<br>&gt;&gt;&gt;&gt; a = range(10)<br>&gt;&gt;&gt;&gt; b = 16<br>&gt;&gt;&gt;&gt; c = ""<br>&gt; .... (some variables)<br>&gt;&gt;&gt;&gt; z = ["this","that","none"]<br>&gt; I then need a command that will list the variables I assigned like:<br>&gt;&gt;&gt;&gt; some_command<br>&gt; a, b, c, ... (some variables), z<br><br>dir()<br><br>&gt;&gt;&gt; a = range(10)<br>&gt;&gt;&gt; b =
 16<br>&gt;&gt;&gt; c = ""<br>&gt;&gt;&gt; z = ["this","that","none"]<br>&gt;&gt;&gt; dir()<br>['__builtins__', '__doc__', '__name__', '__package__', 'a', 'b', 'c', 'z']<br><br>_______________________________________________<br>Tutor maillist&nbsp; -&nbsp; <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>