On Sun, 15 Jul 2012 18:47:38 +1000 Nick Coghlan <ncoghlan at 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.
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4