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 )
|
|
_yield (self)
executed during a yield statement by previous stage |
_yield(self)
executed during a yield statement by previous stage
This method is private within the scope of the flow module, it is used
by one stage in the flow to ask a subsequent stage to produce its
value. The result of the yield is then stored in self.result and is an
instance of Failure if a problem occurred.
-
- Overrides:
twisted.flow.base.Stage._yield (inherited documentation)
|