Package twisted :: Package flow :: Module stage :: Class Map

[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)`
| ``_yield`(self)` executed during a yield statement by previous stage
Inherited from Stage
| ``__iter__`(self)`
| ``next`(self)` return current result

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 2.0 on Sat May 15 20:07:55 2004 | http://epydoc.sf.net