Re: Initializing subclasses of tuple

2005-03-03 Thread Steven Bethard
Nick Coghlan wrote: Any volunteers out there willing to put some words about __new__ together for the main Python docs, please consider posting them on SF :) Done. http://sourceforge.net/tracker/?func=detailaid=1156412group_id=5470atid=105470 STeVe --

Re: Initializing subclasses of tuple

2005-03-02 Thread Nick Coghlan
gry@ll.mit.edu wrote: To inherit from an immutable class, like string or tuple, you need to use the __new__ member, not __init__. See, e.g.: http://www.python.org/2.2.3/descrintro.html#__new__ Any volunteers out there willing to put some words about __new__ together for the main Python docs,

Initializing subclasses of tuple

2005-03-01 Thread Dave Opstad
I'm hoping someone can point out where I'm going wrong here. Here's a snippet of a Python interactive session (2.3, if it makes a difference): -- class X(list): ... def __init__(self, n): ... v = range(n) ... list.__init__(self, v) ... x = X(10)

Re: Initializing subclasses of tuple

2005-03-01 Thread Steve Holden
Dave Opstad wrote: I'm hoping someone can point out where I'm going wrong here. Here's a snippet of a Python interactive session (2.3, if it makes a difference): -- class X(list): ... def __init__(self, n): ... v = range(n) ... list.__init__(self, v)

Re: Initializing subclasses of tuple

2005-03-01 Thread Just
In article [EMAIL PROTECTED], Dave Opstad [EMAIL PROTECTED] wrote: I'm hoping someone can point out where I'm going wrong here. Here's a snippet of a Python interactive session (2.3, if it makes a difference): -- class X(list): ... def

Re: Initializing subclasses of tuple

2005-03-01 Thread gry
To inherit from an immutable class, like string or tuple, you need to use the __new__ member, not __init__. See, e.g.: http://www.python.org/2.2.3/descrintro.html#__new__ -- http://mail.python.org/mailman/listinfo/python-list