On Jul 2, 10:20 pm, Paul Rubin <http://phr...@nospam.invalid> wrote: > ryles <ryle...@gmail.com> writes: > > >>> # Oh... yeah. I really *did* want 'is None' and not '== None' > > >>> which iter() will do. Sorry guys! > > > Please don't let this happen to you too ;) > > None is a perfectly good value to put onto a queue. I prefer > using a unique sentinel to mark the end of the stream: > > 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 ()', and depending on the type, __eq__ can introduce some avoidable risk. FWIW, even object() has its disadvantages. Namely, it doesn't work for multiprocessing.Queue which pickles and unpickles, thus giving you a new object. One way to deal with this is to define a "Stopper" class and type check objects taken from the queue. This is not news to anyone who's worked with multiprocessing.Queue, though. -- http://mail.python.org/mailman/listinfo/python-list