Commit 0c9a318d authored by Guido van Rossum's avatar Guido van Rossum

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

parent f0dfc7ac
...@@ -140,8 +140,7 @@ by functions or loops that truncate the stream. ...@@ -140,8 +140,7 @@ by functions or loops that truncate the stream.
\begin{verbatim} \begin{verbatim}
def ifilter(predicate, iterable): def ifilter(predicate, iterable):
if predicate is None: if predicate is None:
def predicate(x): predicate = bool
return x
for x in iterable: for x in iterable:
if predicate(x): if predicate(x):
yield x yield x
...@@ -157,8 +156,7 @@ by functions or loops that truncate the stream. ...@@ -157,8 +156,7 @@ by functions or loops that truncate the stream.
\begin{verbatim} \begin{verbatim}
def ifilterfalse(predicate, iterable): def ifilterfalse(predicate, iterable):
if predicate is None: if predicate is None:
def predicate(x): predicate = bool
return x
for x in iterable: for x in iterable:
if not predicate(x): if not predicate(x):
yield x yield x
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment