En Fri, 03 Jul 2009 00:15:40 -0300, <//phr...@nospam.invalid>> escribió:
ryles <ryle...@gmail.com> writes:
> sentinel = object()
I agree, this is cleaner than None. We're still in the same boat,
though, regarding iter(). Either it's 'item == None' or 'item == object
()'
Use "item is sentinel".
We're talking about the iter() builtin behavior, and that uses ==
internally.
It could have used an identity test, and that would be better for this
specific case. But then iter(somefile.read, '') wouldn't work. A
compromise solution is required; since one can customize the equality test
but not an identity test, the former has a small advantage. (I don't know
if this was the actual reason, or even if this really was a concious
decision, but that's why *I* would choose == to test against the sentinel
value).
--
Gabriel Genellina
--
http://mail.python.org/mailman/listinfo/python-list