Binding the names in a module in a class instance

Jacob H jacobsmail at postmark.net
Mon May 23 01:53:21 EDT 2005


Hello all,

I would like to be able to take a module full of class instances,
functions, etc and bind all its names to a separate container class in
a different module. I have come up with the following way to do it..

(module "globals")

class Container:
    pass
container = Container()

(module "all_the_stuff")

...define a bunch of stuff...

(module "main")

exec open("all_the_stuff.py").read() in globals.container.__dict__

I feel uneasy about this method. I foresee bad namespace clashes.
What's a better way? :)

Thanks in advance,
Jacob




More information about the Python-list mailing list