| Home | Trees | Indices | Help |
|
|---|
|
|
Utilities for with-statement contexts. See PEP 343.
|
|||
|
GeneratorContextManager Helper for @contextmanager decorator. |
|||
|
closing Context to automatically close something at the end of a block. |
|||
|
|||
|
|||
|
|||
|
|||
__package__ =
|
|||
Imports: sys
|
|||
@contextmanager decorator.
Typical usage:
@contextmanager
def some_generator(<arguments>):
<setup>
try:
yield <value>
finally:
<cleanup>
This makes this:
with some_generator(<arguments>) as <variable>:
<body>
equivalent to this:
<setup>
try:
<variable> = <value>
<body>
finally:
<cleanup>
|
Support multiple context managers in a single with-statement.
Code like this:
with nested(A, B, C) as (X, Y, Z):
<body>
is equivalent to this:
with A as X:
with B as Y:
with C as Z:
<body>
|
| Home | Trees | Indices | Help |
|
|---|
| Generated by Epydoc 3.0.1 on Tue Apr 12 18:11:54 2011 | http://epydoc.sourceforge.net |