On 01/30/2013 01:54 AM, Nick Coghlan wrote:
On Wed, Jan 30, 2013 at 11:06 AM, Larry Hastings <larry@hastings.org> wrote:
Properties are a wonderful facility.  But they only work on conventional
objects.  Specifically, they *don't* work on module objects.  It would be
nice to extend module objects so properties worked there too.
As MAL notes, the issues with such an approach are:

- code executed at module scope
- code in inner scopes that uses "global"
- code that uses globals()
- code that directly modifies a module's __dict__

There is too much code that expects to be able to modify a module's
namespace directly without going through the attribute access

Of those four issues, the latter two are wontfix.  Code that futzes with an object's __dict__ bypasses the property machinery but this is already viewed as acceptable.

Obviously the point of the proposal is to change the behavior of the first two.  Whether this is manageable additional complexity, or fast enough, remains to be seen--which is why this is in ideas not dev.

Also, I'm not sure there are any existing globals that we'd want to convert into properties.  Assuming this is only used for new globals, this change hopefully wouldn't break existing code.  (Fingers crossed.)