[Python-Dev] Iterator version of contextlib.nested (original) (raw)
Hagen Fürstenau hfuerstenau at gmx.net
Sat Jun 13 14:45:56 CEST 2009
- Previous message: [Python-Dev] Iterator version of contextlib.nested
- Next message: [Python-Dev] Iterator version of contextlib.nested
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
The semantic change actually needed to make nested() more equivalent to the multi-with statement is for it to accept zero-argument callables that create context managers as arguments rather than pre-created context managers.
It seems to me that both passing callables which return managers and passing a generator which yields managers achieve about the same thing. Are you proposing the former just to avoid introducing a new interface?
Rather than changing the name of the function, this could be done by inspecting the first argument for an "enter" method. If it has one, use the old semantics (and issue a DeprecationWarning as in 3.1). Otherwise, use the proposed new semantics.
I guess this is much too late for 3.1, but could we then at least un-deprecate "contextlib.nested" for now? As it is, you get a DeprecationWarning for something like
with contextlib.nested(*my_managers):
without any good way to get rid of it.
- Hagen
- Previous message: [Python-Dev] Iterator version of contextlib.nested
- Next message: [Python-Dev] Iterator version of contextlib.nested
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]