Ah, I think I misunderstood exactly what you were trying to achieve.  To me, that is essentially immutable - if I ever found myself using type.__setattr__ to change a variable I'd have to seriously question what I was doing!  But that would be a way around it, and I don't think it would be possible to implement it fully in python.  On the other hand, the same argument could be made for the introduction of private variables; Class.__var is not private because it can be changed through Class._Class__var.  I'd also consider having to do this to be indicative of a design flaw in my code.<br>

<br><div class="gmail_quote">On Sun, Feb 26, 2012 at 3:56 PM, Victor Stinner <span dir="ltr"><<a href="mailto:victor.stinner@haypocalc.com">victor.stinner@haypocalc.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">

type.__setattr__(Three, 'value', 4) changes the value.<br>
<span class="HOEnZb"><font color="#888888"><br>
Victor<br>
</font></span><div class="im HOEnZb"><br>
> class FinalMeta(type):<br>
><br>
>     def __setattr__(cls, attr, value):<br>
>         if attr in cls.__dict__ or '__done__' in cls.__dict__:<br>
>             raise AttributeError<br>
>         else:<br>
>             type.__setattr__(cls, attr, value)<br>
><br>
>     def __delattr__(cls, attr):<br>
>         raise AttributeError<br>
><br>
><br>
> class Three:<br>
>     __metaclass__ = FinalMeta<br>
>     value = 3<br>
>     __done__ = True   # There may be a neater way to do this...<br>
><br>
> Each of the following examples will fail:<br>
><br>
>>>> Three.another_value = 4<br>
>>>> Three.value = 4<br>
>>>> del Three.value<br>
>>>> three = Three(); three.value = 4<br>
</div><div class="HOEnZb"><div class="h5">_______________________________________________<br>
Python-ideas mailing list<br>
<a href="mailto:Python-ideas@python.org">Python-ideas@python.org</a><br>
<a href="http://mail.python.org/mailman/listinfo/python-ideas" target="_blank">http://mail.python.org/mailman/listinfo/python-ideas</a><br>
</div></div></blockquote></div><br>