> That's mostly available already!
>
> https://www.python.org/dev/peps/pep-0562/
>


Indeed, and I've been using it!

There is also the "clumsy and obscure" method of adding properties to
modules discussed in PEP 549 <https://www.python.org/dev/peps/pep-0549/>:

import sys, types
class _MyModuleType(types.ModuleType):
    @property
    def prop(self, instance, owner):
        ...

sys.modules[__name__].__class__ = _MyModuleType

This would allow creating a module with managed attribute access AND
setting behaviors.

I wonder if this kind of approach might help the folks who want to be able
to manage variable getting and setting behavior outside of a class
namespace--- you could write a module that makes all of its variables
behave just the way you want, and import it like so:

import managed_variables_module as m

m.x = 1 <-- magic
print(m.x)<-- magic

I'll bow out of this discussion now, as I don't have much to add. This was
just a thought.
_______________________________________________
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/2J24OSSXCIELFULDYSZV35Y4O3HROBSX/
Code of Conduct: http://python.org/psf/codeofconduct/

Reply via email to