Feb. 25, 2012
10:28 a.m.
On 2012-02-24, at 9:29 PM, Victor Stinner wrote:
Hum, after thinking twice, using a "frozendict" for type.__dict__ is maybe overkill for my needs (and intrused as noticed Nick). Attached patch for Python 3.3 is a simpler approach: add __final__ special value for class. If this variable is present, the type is constant. Example: --- class Test: __final__=True x = 1
-1 on this. The next move would be adding friend classes and protected methods ;) __setattr__ works perfectly for those purposes. Moreover, you can emulate your idea on unpatched python by using metaclasses. - Yury