[Python-ideas] Re : Undelivered Mail Returned to Sender
grosser.meister.morti at gmx.net
Tue Apr 28 23:46:44 CEST 2009
Pascal Chambon wrote:
> >Mathias Panzenböck a écrit :
> >Pascal Chambon wrote:
> >> I agree with the idea of auto-nesting "with", however in the case you
> >> pointed out, the main problem was the early evaluation of context
> >> managers ;
> >> maybe a solution would be to delay the creation of context managers,
> >> with something like a partial application (cf functools).
> >> Roughly, we'd need a "delayedNested" function, which takes
> >> callables as parameters, and calls/instanciates them inside itself.
> >> Then just call* delayedNested(partial(A,...arguments...), partial(B,
> >> ...arguments...))*/ /to have what you want.
> >It would be much shorter and more readable to manually nest the with
> > -panzi
> Indeed, but the constructions we talk about would allow nesting dozens
> of context managers without any problem ;
> Well then, you'll ask me "what kind of a perverse would need to
> imbricate dozens of context managers ???" ; sincerely I don't know ^^
> But since "flat is better than nested", even just for 2 or 3 context
> managers, I feel a construct like "with A() as a, B() as b, C() as c:"
> is anyway better than 3 nested with statements
Yes I'm +1 for "with A() as a, B() as b, C() as c:", too.
For the deleyedNested(...) thing I'm -1 however.
More information about the Python-ideas