I apologize in advance that this might be slightly off topic from the thread. The idea I want to put forth is probably half baked, but I am wondering if Nate's implementation might be adjusted to incorporate it, and if it might solve a few of the objections.
Hopefully someone hasn't already suggested it; I've tried to follow the discussion about this the past couple weeks but there are a lot of messages. The elevator pitch version: add descriptors to modules. Suggested syntax: # inside of my_module a = 1 <-- this does not change # if i specifically want to access a using the of the CURRENT module, i prefix a dot: print(.a) <--- access of a occurs via my_module.__getattr__() when inside my_module # if i specifically want to set a using the (currently not existent) __setattr__() fo the CURRENT module, i do a simliar thing: .a = 2 <-- setting occurs via my_module.__setattr__() when inside my_module In this way, the usage of the module-level attribute getting and setting is entirely VOLUNTARY, and you would expect surprising things to happen when you use the dot. All of the "normal" ways we access variables, which are just names anyway, remain in force: # no changes a = 1 print(a) a = 2 This could be extended to work in other modules: # your_module import my_module my_module.x = 1 <-- magic may occur print(my_module.x) <-- magic may occur Again, this is definitely half baked and I am probably missing something very wrong with it. And I'm sure it has been brought up before. Just throwing it out there as a possible idea related to his discussion. Rick.
_______________________________________________ Python-ideas mailing list -- python-ideas@python.org To unsubscribe send an email to python-ideas-le...@python.org https://mail.python.org/mailman3/lists/python-ideas.python.org/ Message archived at https://mail.python.org/archives/list/python-ideas@python.org/message/BBKVC5GRRR4EVKRHUZTIEQED2SBWWOGP/ Code of Conduct: http://python.org/psf/codeofconduct/