__init__ in subclass of tuple

Alan Isaac aisaac at american.edu
Sat Mar 10 00:36:41 EST 2007


I am probably confused about immutable types.
But for now my questions boil down to these two:

- what does ``tuple.__init__`` do?
- what is the signature of ``tuple.__init__``?

These questions are stimulated by
http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/303439
Looking at that, what fails if I leave out the following line? ::

    tuple.__init__(self)

For exaple, if I try::

    class Test1(tuple):
        def __init__(self,seq):
            pass

I seem to get a perfectly usable tuple.
What initialization is missing?

Next, the signature question.
I'm guessing the signature is something like
tuple.__init__(self, *args, **kwargs)
with nothing done with anything but self.
As a trivial illustrative example::

    class Test2(tuple):
        def __init__(self,seq):
            tuple.__init__(self, "foo", "bar")

seems to cause no objections.

One last question: where should I have looked
to answer these questions?

Thanks,
Alan Isaac





More information about the Python-list mailing list