Message89607
I was debugging a class where I defined __getitem__ and __iter__, but
not __contains__. The documentation describing this case (at the end of
section 5.9) is old and hasn't been updated for the iterator protocol.
It should read something like:
"For user-defined classes which do not define __contains__() and do
define __iter__() or __getitem__(), x in y is true if and only if there
is a value z reachable from iter(y) before iter(y) throws a
StopIteration exception. (If any other exception is raised, it is as if
in raised that exception)."
Or something better worded.
(I'm using Python 2.5, but I really doubt things have changes in 2.6 or
2.7. I don't know enough about 3.0 to know either way.) |
|
Date |
User |
Action |
Args |
2009-06-22 19:27:54 | afoglia | set | recipients:
+ afoglia, georg.brandl |
2009-06-22 19:27:54 | afoglia | set | messageid: <1245698874.13.0.640137390853.issue6324@psf.upfronthosting.co.za> |
2009-06-22 19:27:52 | afoglia | link | issue6324 messages |
2009-06-22 19:27:52 | afoglia | create | |
|