I am a relative nobody in Python, however a few weeks ago, I suggested more
harmonization with JavaScript. Admittedly I've been doing more JS lately, so I
might have JS-colored glasses on, but it looks like you're trying to add
lexical scoping to Python, and there's a whole lot of manual scope work going
on. (This may be a result of showing what can be done, rather than what can
typically be done). I am probably entirely mistaken, however when I saw the
subject and started reading, I expected to see something like
v = context.Var({'some': value, 'other': value}) # (wherein Var() would
make deep copies of the values) why repeat `var` after context ? if Var is the
only point of context module?
But that's not what I saw. I didn't immediately grasp that `value` and
`description` (aka. `doc`) were special properties for an individual context
var. This is likely an issue with me, or it could be documentation.
Then it went on to talk about using `with` for managing context. So it looks
like the `with` is just providing a value stack (list) for the variable? Can
this be done automatically with a _setattr_ and append()?
Having done a lot of HTML5 Canvas drawing
(https://developer.mozilla.org/en-US/docs/Web/API/CanvasRenderingContext2D/save)
, this reminds me of `save()` and `restore()`, which would likely be more
familiar to a larger audience. Additionally what about:
with context.save() as derived_context: # or just `with context as
derived_context:` calling save automatically
# whatever
# automatically call restore on __exit__.
I also wonder about using multiple context Vars/managers with `with`, as that
statement would get quite long.
Finally, would it be possible to pass a dict and get membered object out? Using
v from the example above, i.e.: v.value, v.other where gets/sets automatically
use the most recent context?
_______________________________________________
Python-ideas mailing list
[email protected]
https://mail.python.org/mailman/listinfo/python-ideas
Code of Conduct: http://python.org/psf/codeofconduct/