[Python-ideas] PEP draft: context variables
Koos Zevenhoven
k7hoven at gmail.com
Tue Sep 5 11:48:49 EDT 2017
More information about the Python-ideas mailing list
Tue Sep 5 11:48:49 EDT 2017
- Previous message (by thread): [Python-ideas] PEP draft: context variables
- Next message (by thread): [Python-ideas] PEP draft: context variables
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
On Tue, Sep 5, 2017 at 10:43 AM, Pavol Lisy <pavol.lisy at gmail.com> wrote: > On 9/4/17, Koos Zevenhoven <k7hoven at gmail.com> wrote: > [...] > > > with cvar.assign(new_value): > > assert cvar.value is new_value > > # Any code here, or down the call chain from here, sees: > > # cvar.value is new_value > > # unless another value has been assigned in a > > # nested context > > assert cvar.value is new_value > > # the assignment of ``cvar`` to ``new_value`` is no longer visible > > assert cvar.value == "the default value" > > I feel that of "is" and "==" in assert statements in this PEP has to > be used (or described) more precisely. > The use is quite precise as it is now. I can't use `is` for the string values, because the result would depend on whether Python gives you the same str instance as before, or a new one with the same content. Maybe I'll get rid of literal string values in the description, since it seems to only cause distraction. > > What if new_value above is 123456789? > Any value is fine. > > maybe using something like could be better? -> > > def equals(a, b): > return a is b or a == b > > Doesn't PEP need to think about something like "context level overflow" ? > > Or members like: cvar.level ? > I don't see any need for this at this point, or possibly ever. ––Koos -- + Koos Zevenhoven + http://twitter.com/k7hoven + -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://mail.python.org/pipermail/python-ideas/attachments/20170905/e515a820/attachment.html>
- Previous message (by thread): [Python-ideas] PEP draft: context variables
- Next message (by thread): [Python-ideas] PEP draft: context variables
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
More information about the Python-ideas mailing list