Problem subclassing tuple

Aahz aahz at pythoncraft.com
Tue Apr 29 12:22:14 EDT 2003


In article <mailman.1051631814.18940.python-list at python.org>,
John Wilson <tug at wilson.co.uk> wrote:
>
>class Holder(tuple):
>    def __init__(self, *values):
>        tuple.__init__(self, values)
>
>When I try to create an instance:
>
>Holder(1, 2)
>
>I get:
>TypeError: tuple() takes at most 1 argument (2 given)

Use __new__ instead of __init__.
-- 
Aahz (aahz at pythoncraft.com)           <*>         http://www.pythoncraft.com/

"In many ways, it's a dull language, borrowing solid old concepts from
many other languages & styles:  boring syntax, unsurprising semantics,
few automatic coercions, etc etc.  But that's one of the things I like
about it."  --Tim Peters on Python, 16 Sep 93




More information about the Python-list mailing list