On Sun, 15 Jul 2012 18:47:38 +1000 Nick Coghlan <ncogh...@gmail.com> wrote: > > > * __length_hint__ should be allowed to return None to indicate "don't know" > > or -1 to indicate "infinite". > > > > Presumably anything that wishes to create a list or other sequence from an > > object with a hint of -1 could then raise an exception immediately. > > I'm not seeing the value in returning None over 0 for the don't know > case - it just makes the API harder to use.
The point is that 0 is a legitimate value for a length hint. Simple implementations of __length_hint__ will start returning 0 as a legitimate value and you will wrongly interpret that as "don't know", which kinds of defeat the purpose of __length-hint__ ;) That said, I don't think a special value for "is infinite" is useful. Just make -1 mean "I don't know". Regards Antoine. _______________________________________________ Python-Dev mailing list Python-Dev@python.org http://mail.python.org/mailman/listinfo/python-dev Unsubscribe: http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com