[Zope3-dev] Re: [Zope3-checkins] SVN: Zope3/trunk/src/zope/schema/interfaces.py - add IIterableChoice and note the desire to depricate vocabularies

Tim Peters tim.peters at gmail.com
Mon Sep 5 12:46:47 EDT 2005


[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.


More information about the Zope3-dev mailing list