unable to read the __main__ namespace

vsoler vicente.soler at gmail.com
Sun Dec 13 06:20:03 EST 2009


I'm learning Python, and I am very fond of it.

Using Python 2.6

I am able to list all the names in a class namespace:

class abc: pass
abc.a1=7
abc.a2='Text'

print abc.__dict__.keys()

a) However, I do not know how to read the __main__ namespace

print __main__.__dict__.keys()    # Just does not work

b) How do i read an imported module namespace?

c) How could I possibly list the names and contents of the namespace
of my python session?

Thank you for your help.

Vicente Soler



More information about the Python-list mailing list