[Tutor] problem when subclassing tuple

Gregor Lingl glingl at aon.at
Sun Jan 25 06:28:59 EST 2004



Thanks, Karl, for this idea ...

>Maybe I don't understand what you want to achieve exactly but what about
>overriding __new__ instead of __init__? (I had the idea when I read
>descintro.html)
>class vec(tuple):
>    def __new__(cls, x,y,z):
>        return tuple.__new__(cls, [x,y,z])
>
>
>  
>
It works well. And also for your hint to 
http://www.python.org/2.2.2/descrintro.html,
which contains all the information I need.

Gregor




More information about the Tutor mailing list