This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author kristjan.jonsson
Recipients AlexWaygood, barry, eric.snow, gvanrossum, kristjan.jonsson, ncoghlan, r.david.murray
Date 2022-01-03.10:35:01
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1641206101.29.0.325471433145.issue18677@roundup.psfhosted.org>
In-reply-to
Content
Great throwback.

As far as I know, context managers are still not first class citizens.  You cannot _compose_ two context managers into a new one programmatically in the language, in the same way that you can, for instance, compose two functions.  Not even using "eval()" is this possible.  

This means that the choice of context manager, or context managers, to be used, has to be known when writing the program.  You cannot pass an assembled context manager in as an argument, or otherwise use a "dynamic" context manager at run time, unless you decide to use only a fixed number of nested ones. any composition of context managers becomes syntax _at the point of invocation_.

The restriction is similar to not allowing composition of functions, i.e. having to write

`fa(fb(fc()))` at the point of invocation and not have the capability of doing
```
def fd():
  return fa(fb(fc))
...
fd()
```

I think my "ContextManagerExit" exception provided an elegant solution to the problem and opened up new and exciting possibilities for context managers and how to use them.

But this here note is just a lament.  I've stopped contributing to core python years ago, because it became more of an excercise in lobbying than anything else.
Cheers!
History
Date User Action Args
2022-01-03 10:35:01kristjan.jonssonsetrecipients: + kristjan.jonsson, gvanrossum, barry, ncoghlan, r.david.murray, eric.snow, AlexWaygood
2022-01-03 10:35:01kristjan.jonssonsetmessageid: <1641206101.29.0.325471433145.issue18677@roundup.psfhosted.org>
2022-01-03 10:35:01kristjan.jonssonlinkissue18677 messages
2022-01-03 10:35:01kristjan.jonssoncreate