>
> I hope you see now why it is consistent.
>
> Georg
yea that clears it up. thanks.
--
http://mail.python.org/mailman/listinfo/python-list
abcd schrieb:
>> As an immutable type, tuple makes use of __new__.
>>
>> class MyTuple(tuple):
>> def __new__(cls, *args):
>> return tuple.__new__(cls, args)
>>
>> should work.
>>
>> Georg
>
> strange. not very consistent.
On the contrary -- __new__ *and* __init__ exist for all typ
> As an immutable type, tuple makes use of __new__.
>
> class MyTuple(tuple):
> def __new__(cls, *args):
> return tuple.__new__(cls, args)
>
> should work.
>
> Georg
strange. not very consistent.
--
http://mail.python.org/mailman/listinfo/python-list
abcd <[EMAIL PROTECTED]> wrote:
> I wanted to extend tuple but ran into a problem. Here is what I
> thought would work
I think you should take a look at this to do it properly from the Python
devs:
http://svn.python.org/view/python/trunk/Lib/collections.py
Look for NamedTuple
--
Lawrence, oluy
abcd schrieb:
> I wanted to extend tuple but ran into a problem. Here is what I
> thought would work
>
> class MyTuple(tuple):
> def __init__(self, *args):
> tuple.__init__(self, args)
>
> x = MyTuple(1,2,3,4)
>
> That gives me...
>
> TypeError: tuple() takes at most 1 argument (4
I wanted to extend tuple but ran into a problem. Here is what I
thought would work
class MyTuple(tuple):
def __init__(self, *args):
tuple.__init__(self, args)
x = MyTuple(1,2,3,4)
That gives me...
TypeError: tuple() takes at most 1 argument (4 given).
However, this call works:
x