-->

Friday, October 17, 2008

Listing variables (e.g IDL help) in Python

Again, IDL has the simple 'help' command to tell you all variables in your namespace. Python has the same thing, but the namespace tends to be cluttered with imported functions. The commands who, who_ls, and whos are meant for interactive use. They are a hell of a lot more useful than var, locals, globals, and dir.

examples:

whos float
whos ndarray
who module
float_vars = %who_ls float
grep('x',float_vars)


I'm afraid I don't know how to make the last two lines into a one-liner, as would be desirable.

No comments: