Re: Question about extending tuple

2007-03-29 Thread abcd
> > I hope you see now why it is consistent. > > Georg yea that clears it up. thanks. -- http://mail.python.org/mailman/listinfo/python-list

Re: Question about extending tuple

2007-03-28 Thread Georg Brandl
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

Re: Question about extending tuple

2007-03-28 Thread abcd
> 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

Re: Question about extending tuple

2007-03-28 Thread Lawrence Oluyede
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

Re: Question about extending tuple

2007-03-28 Thread Georg Brandl
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

Question about extending tuple

2007-03-28 Thread abcd
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