[Fred Drake, on returning sys.maxint from __len__ if you don't know
 the length, which Tim strongly advises against]
> Interesting.  I seem to remember this coming from Guido several times
> in discussions.

Not me.  Googling on

    site:mail.python.org maxint __len__  guido

finds 9 hits, all irrelevant.  There's no instance of returning
sys.maxint from a __len__ method in the Python codebase; there are
instances of returning small constants.

> The Python community needs to settle on a recommendation for this and
> document it in the Language Reference.

If you don't/can't know the length, return "a typical" size, or leave
__len__() undefined (in which latter case CPython will usually guess
8).  As the code example I gave before showed, returning sys.maxint
creates needless problems.
Zope3-dev mailing list
Unsub: http://mail.zope.org/mailman/options/zope3-dev/archive%40mail-archive.com

Reply via email to