Author andreash
Recipients andreash, ncoghlan, serhiy.storchaka, yselivanov
Date 2021-09-13.19:42:25
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1631562146.07.0.400667555203.issue45184@roundup.psfhosted.org>
In-reply-to
Content
I see your point. But even with `pop` or `remove` it is still a stack or stack-like. In the normal case the context managers are still released in reverse order as they were added. Order cannot be changed arbitrarily.

There is just the additional function of removing a single context manager prematurely(e.g. for graceful error recovery and such). 

I would perhaps say that a stack is the "wrong" solution to the problem of "programmatically combining context managers" [this is from the official documentaion] in the first place. I write wrong in quotes because it is of course not really wrong, as one wants the reverse exit order. But to adequately address the dynamic case one needs in my opinion the ability to prematurely remove context managers. Otherwise the use is limited.

Reimplemeting the desired functionality with dicts or lists does not seem appealing to me as the code will be 90% the same to ExitStack. It will then also make ExitStack obsolete. So why not integrate it there?

The unsymmetry of being able to add context managers but not being able to remove them also seems odd to me.
History
Date User Action Args
2021-09-13 19:42:26andreashsetrecipients: + andreash, ncoghlan, serhiy.storchaka, yselivanov
2021-09-13 19:42:26andreashsetmessageid: <1631562146.07.0.400667555203.issue45184@roundup.psfhosted.org>
2021-09-13 19:42:26andreashlinkissue45184 messages
2021-09-13 19:42:25andreashcreate