Multi thread reading a file

Gabriel Genellina gagsl-py2 at yahoo.com.ar
Thu Jul 2 23:47:54 EDT 2009


En Fri, 03 Jul 2009 00:15:40 -0300, <//phr.cx at nospam.invalid>> escribió:

> ryles <rylesny at 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




More information about the Python-list mailing list