Re: Generating modul classes with eval

2005-02-03 Thread Axel Straschil
Hello! > After the loop has finished, the global variable TmpClass will be bound to > whatever class was created last, and the variable class_base will be bound > to that the base class of that same TmpClass. Therefore only this last class > is guaranteed to work as expected. Great, now it workes

Re: Generating modul classes with eval

2005-02-03 Thread Peter Otten
Axel Straschil wrote: > class_dic = {} > class_dic['Br'] = _Tag > class_dic['Hr'] = _Tag > class_dic['Html'] = _ContainerTag > class_dic['Table'] = _ContainerTag > > for class_name, class_base in class_dic.items(): > class TmpClass(class_base): > def __init__(self, **props): >

Re: Generating modul classes with eval

2005-02-03 Thread Axel Straschil
Hello! > Note that we don't need eval anywhere. Uuups, that looks realy cool! Thanks for that! Im fooling around with generating html-tags. As there are only two kind of html tags, one who can nest chields, and one who cant, i wantet to play arround with something like: I've got two base classe

Re: Generating modul classes with eval

2005-02-02 Thread Jeremy Bowers
On Wed, 02 Feb 2005 16:20:41 -0500, Jeremy Bowers wrote: > That said, "__main__" indicates you ran it in the interactive shell. Or ran it directly on the command line. Duh. I thought that clause really loudly, but I guess I never actually typed it. -- http://mail.python.org/mailman/listinfo/pytho

Re: Generating modul classes with eval

2005-02-02 Thread Jeremy Bowers
On Wed, 02 Feb 2005 20:49:07 +, Axel Straschil wrote: You are doing several things wrong. > I was fooling around with creating classes for a module with eval, You shouldn't create classes with eval, because you don't need to. "class" isn't a declaration, it is an executable statement that c

Re: Generating modul classes with eval

2005-02-02 Thread Steve Holden
Axel Straschil wrote: 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,

Generating modul classes with eval

2005-02-02 Thread Axel Straschil
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).__in