Kevin Reeder wrote:
This is not my code but is taken from the book I'm working with. My
problem is that whenever I call to the __add__ method the counters
increase by 2 while calls the __len__ method increase the counters
by 1 as expected.

Well, I can't duplicate your results.. I get the behaviour you expect. Also ---



A + [4, 5, 6]

[1, 2, 3, 4, 5, 6]

This surprises me. Here's what I get:

>>> A + [3, 4, 5]
<__main__.MyList instance at 0x40065e4c>

because you haven't defined __repr__ for MyList.

Are you sure you've giving us all the code?

--
John.
_______________________________________________
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor

Reply via email to