Use 'predicate = bool' as the default predicate for ifilter[false].

This commit is contained in:
Guido van Rossum 2003-10-20 17:01:07 +00:00
parent f0dfc7ac5c
commit 0c9a318d64

View file

@ -140,8 +140,7 @@ by functions or loops that truncate the stream.
\begin{verbatim}
def ifilter(predicate, iterable):
if predicate is None:
def predicate(x):
return x
predicate = bool
for x in iterable:
if predicate(x):
yield x
@ -157,8 +156,7 @@ by functions or loops that truncate the stream.
\begin{verbatim}
def ifilterfalse(predicate, iterable):
if predicate is None:
def predicate(x):
return x
predicate = bool
for x in iterable:
if not predicate(x):
yield x