Re: newbie class-building question

2006-11-09 Thread Gabriel Genellina
At Thursday 9/11/2006 09:30, jrpfinch wrote: I am constructing a simple class to make sure I understand how classes work in Python (see below this paragraph). It works as expected, except the __add__ redefinition. I get the following in the Python interpreter: >>> a=myListSub() >>> a [] >>> a

Re: newbie class-building question

2006-11-09 Thread Jon Clements
jrpfinch wrote: > Thank you this is very helpful. The only thing I now don't understand > is why it is calling __coerce__. self.wrapped and other are both > lists. Yes, but in "a + [5]", *a* is a myListSub object -- it's not a list! So __coerce__ is called to try and get a common type... Try

Re: newbie class-building question

2006-11-09 Thread jrpfinch
Thank you this is very helpful. The only thing I now don't understand is why it is calling __coerce__. self.wrapped and other are both lists. Thanks Jon -- http://mail.python.org/mailman/listinfo/python-list

Re: newbie class-building question

2006-11-09 Thread Jon Clements
jrpfinch wrote: > I am constructing a simple class to make sure I understand how classes > work in Python (see below this paragraph). > > It works as expected, except the __add__ redefinition. I get the > following in the Python interpreter: > > >>> a=myListSub() > >>> a > [] > >>> a+[5] > Trace

Re: newbie class-building question

2006-11-09 Thread Peter Otten
jrpfinch wrote: > I am constructing a simple class to make sure I understand how classes > work in Python (see below this paragraph). > > It works as expected, except the __add__ redefinition. I get the > following in the Python interpreter: > a=myListSub() a > [] a+[5] > Traceba

newbie class-building question

2006-11-09 Thread jrpfinch
I am constructing a simple class to make sure I understand how classes work in Python (see below this paragraph). It works as expected, except the __add__ redefinition. I get the following in the Python interpreter: >>> a=myListSub() >>> a [] >>> a+[5] Traceback (most recent call last): File "