Mercurial > slides-fragments
changeset 154:b2ef5d3a915d
created
| author | 127.0.0.1 |
|---|---|
| date | Thu, 30 Jan 2014 09:40:18 +0100 |
| parents | 2c79d262fe2f |
| children | fdc42dcd8d80 |
| files | multiple%20with |
| diffstat | 1 files changed, 20 insertions(+), 0 deletions(-) [+] |
line wrap: on
line diff
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/multiple%20with Thu Jan 30 09:40:18 2014 +0100 @@ -0,0 +1,20 @@ +**Wrong:** +{{{#!python +with X() as x: + with Y() as y: + do_something(x, y) +}}} + +**Better:** +{{{#!python +with X() as x, Y() as y: + do_something(x, y) +}}} + +**Older pythons:** +{{{#!python +import contextlib + +with contextlib.nested(X(), Y()) as x, y: + do_something(x, y) +}}} \ No newline at end of file
