Possible constant assignment operators ":=" and "::=" for Python
Edward Elliott
nobody at 127.0.0.1
Fri May 12 14:40:54 EDT 2006
Piet van Oostrum wrote:
>>>>>> tsaar2003 at yahoo.com (T) wrote:
>
>>T> As you can see, the "constant" A can be modified this easily. But if
>>T> there were an intuitive mechanism to declare a symbol to be immutable,
>>T> then there won't be this problem.
>
> Mutability is not a property of symbols but of values. So it doesn't make
> sense to declare an identifier to be immutable. And mutability is tied to
> the object's type, not to individual instances.
I think he meant immutable binding, not immutable symbol. So
rebinding/overshadowing a "constant" A would raise an error, but mutating
the underlying object A refers to would not (unless it too were immutable).
As far objects themselves, adding an ability to make any object immutable
regardless of type is exactly what he suggests.
--
Edward Elliott
UC Berkeley School of Law (Boalt Hall)
complangpython at eddeye dot net
More information about the Python-list
mailing list