[Tutor] question about listing variables defined since session started
Alan Gauld
alan.gauld at btinternet.com
Tue May 1 01:43:32 CEST 2012
On 30/04/12 22:25, Comer Duncan wrote:
> I have a newbie type question. Say I have started a python (or
> ipython) session and have done some imports and have also defined some
> new variables since the session started. So, I have in my current
> namespace a bunch of things. Suppose I want to list just those
> variable names which have been defined since the session started
You could save the initial startup state then later do a delta.
Saving startup state only needs doing once since it should be
the same each time - unless you define local startup commands - in
whioch case you will need to regenerate the startup state..
> not include the names of the objects that who and whos will return.
What are who and whos?
They are not defined in my version of Python...
> How to do that? In matlab, this is what the who returns,
No idea what Matlab does, sorry.
> python I seem to always get a raft of things since I typically do
> import a bunch of things.
So I'm guessing you don't want any of the imported stuff?
What if you define a variable in an imported module?
Should that be listed or not?
But basically I think you want locals() - startup()
[where you define startup as described above]
--
Alan G
Author of the Learn to Program web site
http://www.alan-g.me.uk/
More information about the Tutor
mailing list