As Greg pointed..

g = {}
exec open('t.py').read() in g, g

is what you want.

But you can write it also this way:
exec open('t.py').read() in {}

because if you specify only globals, the same
dictionary is also used for locals. (locals() is
used as a default only if you don't specify globals)

OR

explicitly move class Foo to globals

t.py contains:
globals Foo
class Foo: pass
class Bar:
     f = Foo 

(Should work. I haven't tried it, though)

BranoZ

-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to