new module and class/type unification.

Martin v. Loewis martin at v.loewis.de
Fri Jul 26 03:07:36 EDT 2002


Fredrik Stenberg <mail at fredriks.org> writes:

> import new
> new.instance(str,None)
> Traceback (most recent call last):
>   File "<stdin>", line 1, in ?
> TypeError: instance() argument 1 must be class, not type
> 
> 
> Is this is a bug? or am i missing the big picture
> in type/class unification and the new-module?

It's not a bug: new.instance creates only instance objects (i.e. whose
type is types.InstanceType). For a type, you can call the type's __new__:

>>> str.__new__(str)
''

HTH,
Martin



More information about the Python-list mailing list