Generating modul classes with eval
Axel Straschil
axel at straschil.com
Wed Feb 2 15:49:07 EST 2005
More information about the Python-list mailing list
Wed Feb 2 15:49:07 EST 2005
- Previous message (by thread): Finding user's home dir
- Next message (by thread): Generating modul classes with eval
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Hello! I was fooling around with creating classes for a module with eval, something like: MyModule.py: class Base: init(self, name): self._name = name for myclass in ['A', 'B', 'C']: code="class %s(Base):\n\tinit(self, name='%s')\n\t\tsuper(%s, self).__init(name=name)\n"%dict(myclass, myclass.lower(), myclass()) ... codeop and eval stuff ... a=A() print a that gives: <class '__main__.A'>, but I want MyModule.A ;-) Can someone give me a hint how to create classes in a module with eval and codeop so that they exist like the code was written in? Thanks, AXEL.
- Previous message (by thread): Finding user's home dir
- Next message (by thread): Generating modul classes with eval
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
More information about the Python-list mailing list