with obj1 as o1: with obj2 as o3: with obj3 as o3: код
with obj1 as o1: with obj2 as o3: with obj3 as o3: код
with open('in', 'r') as fin, open('out', 'w') as fout: ...
Changed in version 2.7: Support for multiple context expressions.Я же помнил, что что-то не так.
That means, for example, that using nested() to open two files is a programming error as the first file will not be closed promptly if an exception is thrown when opening the second file.
Убедительно прошу: не используйте contextlib.nested — ибо глюкав в некоторых местах. Правильный способ — contextlib2.ExitStack из http://contextlib2.readthedocs.org/en/latest/
http://code.activestate.com/lists/python-ideas/14609/ — Nick в очередной раз разъясняет проблему.