subclassing tuple

damien morton morton at dennisinter.com
Mon Feb 11 01:43:58 EST 2002


Ive been trying to subclass the tuple type, without a whole lot of success

Heres the code Ive been using:

class triple(tuple):
    def __init__(self, x, y, z):
        tuple.__init__(self, (x,y,z))

>>> t = triple(1,2,3)
Traceback (most recent call last):
  File "<stdin>", line 1, in ?
TypeError: tuple() takes at most 1 argument (3 given)

For some reason, subclasses of tuple dont call the proper __init__ code.

Am I missing something here?



More information about the Python-list mailing list