Ron Garret wrote:
In article <[EMAIL PROTECTED]>,
Steven Bethard <[EMAIL PROTECTED]> wrote:
Why don't you just write a function to create class objects?
def f(*params):
class C(...):
... # based on params
return C
I suppose I could. When I originally started writing this code I wanted
each of the generated classes to have its own name, and I didn't realize
that you could accomplish this by assigning to cls.__name__ after you
created it.
Yeah, that's what I'd do:
py> def f(name):
... class C(object):
... pass
... C.__name__ = name
... return C
...
py> f('D')
<class '__main__.D'>
py> f('Foo')
<class '__main__.Foo'>
STeVe
--
http://mail.python.org/mailman/listinfo/python-list