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/2005-September/056887.html below:

[Python-Dev] bool(container) [was bool(iter([])) changedbetween 2.3 and 2.4]

[Python-Dev] bool(container) [was bool(iter([])) changedbetween 2.3 and 2.4] [Python-Dev] bool(container) [was bool(iter([])) changedbetween 2.3 and 2.4]Fredrik Lundh fredrik at pythonware.com
Fri Sep 30 18:29:58 CEST 2005
Guido van Rossum wrote:

> "Containerish" behavior isn't enough to warrant empty <--> false; in
> some sense every object is a container (at least every object with a
> __dict__ attribute) and you sure don't want to map __len__ to
> self.__dict__.__len__...

the ElementTree experience shows that doing

    def __getitem__(self, index):
        return self.items[index]
    def __len__(self):
        return len(self.items)
    def __nonzero__(self):
        return True

is sometimes a good idea, even for objects that are mostly sequences.

(ET 1.2.X lacks the __nonzero__ method, and accidentally treating
elements with no subelements as if the element itself doesn't exist is by
far the most common gotcha in ET code).

</F> 



More information about the Python-Dev mailing list

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