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 achimnol
Recipients achimnol
Date 2021-06-08.02:38:28
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <>
This is just an idea: ContextVar.set() and ContextVar.reset() looks naturally mappable with the "with" statement.

For example:

a = ContextVar('a')
token = a.set(1234)

could be naturally rewritten as:

a = ContextVar('a')
with a.set(1234):

Is there any particular reason *not* to do this?
If not, I'd like make a PR to add this API.
Naming suggestions of this API are welcome, but it also seems possible to keep it "set()" if we retain the reference to the ContextVar instance in the Token instance.
Date User Action Args
2021-06-08 02:38:29achimnolsetrecipients: + achimnol
2021-06-08 02:38:29achimnolsetmessageid: <>
2021-06-08 02:38:29achimnollinkissue44343 messages
2021-06-08 02:38:28achimnolcreate