Dynamic class construction?
David C. Ullrich
ullrich at math.okstate.edu
Mon Jan 31 11:28:25 EST 2000
Adrian Eyre wrote:
> [...]
>
> There's already a module which does this...
>
> import new
>
> def anOp(self):
> return 'This is an instance of the class %s' % \
> self.__class__.__name__
>
> someOps={'__str__':anOp}
> G=new.classobj('G', (Group,), someOps) # Group defined elsewhere
I sorta thought there might be a module that does this, but I
couldn't find it.
Um, I still can't find it. It appears to be a builtin module -
new.__doc__
says
' Functions to create new objects used by the interpreter.
You need to know a great deal about the interpreter to use this!',
which is helpful, I guess, but I can't find any more about it in
the docs (or I'm not looking in the right place? It's not in the
"module index", I don't find any interesting files contaning
the text "classobj", etc.)
This means I got the docs-for-weenies and it's documented
in the manly version, or what?
> --------------------------------------------
> Adrian Eyre <a.eyre at optichrome.com>
> http://www.optichrome.com
More information about the Python-list
mailing list