PEP 726: Module __setattr__ and __delattr__

I haven’t yet read this PEP but it sounds like my idea for using the module object as the global namespace would give the desired behaviour. I had prototype that was passing nearly all tests so I think the backwards compatibility issues are not too horrible. A high level summary of my idea is that global lookups do getattr() on a module object, rather than __getitem__() on a dictionary-like object. The import machinery would pass around module objects rather than the module globals dict, like it currently does. Maybe my idea is not very good or not explained very well. As Guido suggested, I should write a PEP for it.

3 Likes