On Jun 25, 2019, at 14:00, nate lust email@example.com wrote:
This message is related to two previous threads, but was a sufficiently evolved to warrant a new topic.
I am proposing that two new magic methods be added to python that will control assignment and loading of class instances. This means that if an instance is bound to a variable name, any attempts to rebind that name will result in a call to the __setself__ (name negotiable) of the instance already bound to that name. Likewise when a class instance bound to a name is loaded by the interpreter, if present, the __getself__ method of that instance will be called and its result will be returned instead. I have been internally calling these cloaking variables as they "cloak" the underlying instance, parallelling the idea of shadowing. Feel free to suggest better names.
Does this still have the same issues as your previous version, like sometimes working for locals and sometimes not, affecting values stored in dicts that aren’t namespaces, not working for namespaces that aren’t dicts (slots classes, custom modules, etc.), type doing the wrong thing, and so on?