[Python-ideas] "Immutable Builder" Pattern and Operator

Ned Batchelder ned at nedbatchelder.com
Mon Jan 23 14:24:15 EST 2017


On 1/23/17 1:27 PM, Gerald Britton wrote:
>
>
> On Jan 23, 2017 1:12 PM, "Britton, Gerald" <Gerald.Britton at td.com
> <mailto:Gerald.Britton at td.com>> wrote:
>
>
>      
>
>     You're mixing up value immutability with name immutability. The name
>
>     isn't immutable, but:
>
>
> Er...No. I'm not confused at all, unless you define immutability in a
> new way.. you said that the "value bound to long_name is immutable."
> It's not. Your example below proves it. 
>
> An immutable object is one whose state cannot be modified once set.
> That's not happening here.  The state of the object bound to
> long_name, which is a pointer to an instance of you class, changes
> with each line.

In Python, names refer to values.  Values can be immutable. Ints,
strings, and tuples are examples of immutable values. They cannot be
mutated.

In Python, names cannot be immutable. It is always possible to make an
existing name refer to a new value.

--Ned.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-ideas/attachments/20170123/f218ea42/attachment.html>


More information about the Python-ideas mailing list