Class Filter
Instruction --+
|
Stage --+
|
Pipe --+
|
Filter
flow equivalent to filter: Filter(function, source, ... )
Yield those elements from a source 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,
source,
*trap)
|
| |
process(self,
results,
stop)
|
| Inherited from Pipe |
| |
_yield(self)
executed during a yield statement by previous stage |
| Inherited from Stage |
| |
__iter__(self)
|
| |
next(self)
return current result |