A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://mail.python.org/pipermail/python-dev/2000-March/002928.html below:

[Python-Dev] yeah! for Jeremy and Greg

[Python-Dev] yeah! for Jeremy and Greg [Python-Dev] yeah! for Jeremy and GregKa-Ping Yee ping@lfw.org
Tue, 28 Mar 2000 19:17:27 -0600 (CST)
On Tue, 28 Mar 2000, Barry A. Warsaw wrote:
> 
> Changing the definition of class Nums to
> 
> class Nums:
>     def __getitem__(self, i):
>         if 0 <= i < 10: return i
>         raise IndexError
>     def __len__(self):
>         return 10
> 
> I.e. adding the __len__() method avoids the SystemError.

It should be noted that "apply" has the same problem, with a
different counterintuitive error message:

    >>> n = Nums()
    >>> apply(sum, n)
    Traceback (innermost last):
      File "<stdin>", line 1, in ?
    AttributeError: __len__


-- ?!ng




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