[Tutor] Variables in workspace
Dave Kuhlman
dkuhlman at rexx.com
Sat Oct 13 23:32:12 CEST 2007
On Sat, Oct 13, 2007 at 11:04:05AM +0200, Eli Brosh wrote:
>
> Hello
> I am working with python interactively using IDLE.
>
> Since starting, I defined some variables:
> s='string'
> a=1
> b=[1,2]
> c=1.02
>
> and so on.
>
> Now, I want to know which variables are in my workspace.
> That is, is there a command similar to "who" in MATLAB ?
> I want to call "who"
> and get the output:
> s a b c
> (a listing of all the variables I defined in the session)
>
> Now, is there a way to clear some or all the variables in that list ?
What is your purpose? What is your use case?
Usually, when this question or its spawn come up on this list, the
answer (and the right one, I think) is: Do not use separate
variables, use keys in a dictionary.
And, you might think: But that's not what I asked for. However, as
your mother might say: That's what's good for you.
Also, remember, in Python, global variables are just entries in the
dictionary returned by globals(), anyway.
Dave
--
Dave Kuhlman
http://www.rexx.com/~dkuhlman
More information about the Tutor
mailing list