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
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
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
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
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
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 "