Python strict mode?

Patrick Sabin patrick.just4fun at gmail.com
Sun Sep 13 22:04:38 CEST 2009


  > You could write a class with a custom __setattr__() method that checks
> for valid attribute names for that class (a list of strings given to
> it's __init__() method). That way you could form several restricted
> "namespaces" for variables simply as different instances of that class.
> 

This can be easier accomplished using __slots__, e.g.:

 >>> class X(object):
...     __slots__ = ['a']

> But in my opinion, it isn't worth it. You still don't get compile time
> errors, which is probably the main reason to use strict mode.

I agree.

- Patrick



More information about the Python-list mailing list