Package twisted :: Package flow :: Module stage :: Class Map
[show private | hide private]
[frames | no frames]

Class Map

Instruction --+    
              |    
          Stage --+
                  |
                 Map

Known Subclasses:
Zip

flow equivalent to map:  Map(function, stage, ... )

Apply a function to every item yielded and yield the results.
If additional stages are passed, the function must take that
many arguments and is applied to the items of all lists in 
parallel.  If a list is shorter than another, it is assumed
to be extended with None items.    If the function is None,
the identity function is assumed; if there are multiple list
arguments, Map stage returns a sequence consisting of tuples
containing the corresponding items from all lists.

    def fn(val):
        return val + 10
    
    source = flow.Map(fn,range(4))
    printFlow(source)

Method Summary
  __init__(self, func, stage, *stages)
  __iter__(self)
(inherited from Stage)
  next(self)
return current result (inherited from Stage)
  _yield(self)
executed during a yield statement by previous stage

Method Details

_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)

Generated by Epydoc 1.1 on Fri Jun 27 03:47:50 2003 http://epydoc.sf.net