Problem subclassing tuple
John Wilson
tug at wilson.co.uk
Tue Apr 29 13:18:28 EDT 2003
----- Original Message -----
From: "Aahz" <aahz at pythoncraft.com>
[snip]
>
> Use __new__ instead of __init__.
> --
I tried:
... def __new__(cls, *args, **kargs):
... instance = object.__new__(cls)
... tuple.__init__(instance, args)
...
But I got:
>>> Holder(1, 2)
Traceback (most recent call last):
File "<stdin>", line 1, in ?
File "<stdin>", line 3, in __new__
TypeError: object.__new__(Holder) is not safe, use tuple.__new__()
I'm sure I'm being dense. Can you advise me as what to do in the __new__
method?
John Wilson
The Wilson Partnership
http://www.wilson.co.uk
More information about the Python-list
mailing list