Class Filter
Instruction --+
|
Stage --+
|
Filter
flow equivalent to filter: Filter(function, stage, ... )
Yield those elements from a stage for which a function
returns true. If the function is None, the identity
function is assumed, that is, all items yielded that are
false (zero or empty) are discarded.
def odd(val):
if val % 2:
return True
def range():
yield 1
yield 2
yield 3
yield 4
source = flow.Filter(odd,range)
printFlow(source)
| Method Summary |
| |
__init__(self,
func,
stage,
*trap)
|
| |
__iter__(self)
(inherited from Stage)
|
| |
next(self)
return current result (inherited from Stage)
|