Can this be written more concisely in a functional style
Alexander Schmolck
a.schmolck at gmx.net
Tue Nov 18 12:37:15 EST 2003
Dennis Lee Bieber <wlfraed at ix.netcom.com> writes:
> > def all(p, seq):
> > """Returns true if all elements in seq satisfy predicate p."""
> > for elt in itertools.ifilterfalse(p, seq):
> > return False
> > return True
> >
> I'd be wasting a local with
>
> def any(p, seq):
> """ibid"""
> a = False
> for elt in itertools.ifilter(p, seq):
> a = True
break
> return a
You're not just wasting a local.
'as
More information about the Python-list
mailing list