[Python-Dev] bool(container) [was bool(iter([])) changed between 2.3 and 2.4] (original) (raw)
Jim Jewett jimjjewett at gmail.com
Fri Sep 30 17:42:15 CEST 2005
- Previous message: [Python-Dev] linecache problem
- Next message: [Python-Dev] bool(container) [was bool(iter([])) changed between 2.3 and 2.4]
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Python doesn't worry about a precise boolean object, it distinguishes between something and nothing.
Is there anything left?" is a pretty good analogy for iterators.
It isn't always cheaply available, and having might encourage poor style -- so iterators are going back to the default for non-containers of always True.
How general strong is this default-to-true rule?
If I submit a documentation patch, should I say that numbers, lists, strings, dictionaries, and tuples are a special case, or should I just warn that some container-like objects (including iterators) are always True?
More specific question:
A Queue.Queue is always true. Should I submit a bug patch or add it as a beware of custom classes example?
def __nonzero__(self):
return not self.empty()
- Previous message: [Python-Dev] linecache problem
- Next message: [Python-Dev] bool(container) [was bool(iter([])) changed between 2.3 and 2.4]
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]