[Python-ideas] Support other dict types for type.__dict__
Yury Selivanov
yselivanov.ml at gmail.com
Sat Feb 25 05:58:25 CET 2012
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
More information about the Python-ideas
mailing list