Python code for 2.5 and 2.4?
Arnaud Delobelle
arnodel at googlemail.com
Mon Feb 25 18:42:37 EST 2008
On Feb 25, 11:17 pm, Paul Rubin <http://phr...@NOSPAM.invalid> wrote:
> Arnaud Delobelle <arno... at googlemail.com> writes:
> > def all(iterable):
> > for x in iterable:
> > if not x: return False
> > return True
>
> from itertools import imap
> def all(iterable):
> return False not in imap(bool, iterable)
Ok. In that case, the following is probably faster (in fact for long
iterables it may be equivalent to the builtin all):
from itertools import ifilterfalse
def all(iterable):
for _ in ifilterfalse(None, iterable):
return False
return True
But my point was really about not checking for the version but just
checking for the existence of the name 'all'.
--
Arnaud
More information about the Python-list
mailing list