Message182304
Some background: I hit this problem when adding Python 3 compatibility
to one of my libraries, where I had the following code:
from types import ClassType
...
class_ = ClassType(n, (sometype, ), dict(class_attr1='foo',
class_attr2='bar')
It wasn't at all clear how to port this to Python 3, given that
ClassType was gone.
types.new_class looks fair game, but the help is not exactly helpful:
new_class(name, bases=(), kwds=None, exec_body=None)
Create a class object dynamically using the appropriate metaclass.
No indication there as to what type should be passed for kwds or exec_body.
I guessed and, by the sound of it, guessed wrong.
I'd certainly agree that the error message is very misleading.
cheers,
Chris |
|
Date |
User |
Action |
Args |
2013-02-18 08:14:21 | cjw296 | set | recipients:
+ cjw296, terry.reedy, ncoghlan, eric.araujo, daniel.urban, docs@python, Ramchandra Apte |
2013-02-18 08:14:21 | cjw296 | link | issue17179 messages |
2013-02-18 08:14:20 | cjw296 | create | |
|