Problem subclassing tuple

John Wilson tug at wilson.co.uk
Tue Apr 29 11:55:21 EDT 2003


Given this class:

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)

It looks like the constructor for the superclass is being called rather than
the __init__ method on Holder.

I'm obviously missing something here. Do I have to supply a __new__ method?
Any help would be appreciated.

John Wilson
The Wilson Partnership
http://www.wilson.co.uk






More information about the Python-list mailing list