How to copy a ClassObject?

Peter Otten __peter__ at web.de
Tue Mar 20 17:42:51 EDT 2007


Stargaming wrote:

> Leave out the `new` module and use `type()` (exactly the same call as to
> `new.classobj`) to achieve the same effect.

No. new.classobj() creates a classic class whereas type() creates a
new-style class. Also, 

 >>> class First: pass
...
>>> type("Tmp", (First,), {})
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
TypeError: a new-style class can't have only classic bases

Peter



More information about the Python-list mailing list