Lawful != Mutable (was Can Python function return multiple data?)

Rustom Mody rustompmody at gmail.com
Sun Jun 7 12:20:37 EDT 2015


On Saturday, June 6, 2015 at 10:20:49 AM UTC+5:30, Steven D'Aprano wrote:
> On Sat, 6 Jun 2015 01:20 pm, Rustom Mody wrote:
> 
> > On Saturday, June 6, 2015 at 3:30:23 AM UTC+5:30, Chris Angelico wrote:
> 
> >> Congrats! You just proved that an object can itself be immutable, but
> >> can contain references to mutables. Ain't that awesome?
> >> 
> >> Did you have a point?
> > 
> > [Under assumption you are not being facetious...]
> > The word immutuable happens to have existed in English before python.
> > I also happen to have used it before I knew of python
> > The two meanings do not match
> > I am surprised
> > Is that surprising?
> 
> Yes, I am surprised that you are surprised. You have been a regular, and
> prolific, contributor on this forum for some years now, teach Python, blog
> about it. You're quite obviously well-read and experienced. How is it that
> you are surprised by such a fundamental part of not just Python's object
> model, but of real life objects too?
> 
> I suspect you are pretending to be surprised to make a rhetorical point.

Dunno why the fuss...
As someone who often asks for short-simple-self-contained examples,
I would have expected you to prefer clarity of communication over
fidelity of experience??

Anyways...

Did I(rusi) now(2015) find that specific example surprising??

No, but:

1. Questioners here regularly do show similar confusions.
2. I did go through similar decades ago when I first encountered programming
3. And most to the point, just add a little complexity and I (rusi-now)
am as confused as any noob.

A few weeks ago there was this example.
It completely knocked me.
ChrisA's exxplanation clarified.
Here is a reconstruction based on Chris clarification
[Chris do you remember the question?]

>>> t=([1,2],[3,4])
>>> t
([1, 2], [3, 4])
>>> t[1] = t[1].append(5)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
TypeError: 'tuple' object does not support item assignment
>>> t
([1, 2], [3, 4, 5])

> 
> Like many English words, "immutable" has a few meanings in plain English.
> Bouvier's Law Dictionary included in 1856 this definition:
> 
>     IMMUTABLE. What cannot be removed, what is unchangeable.
>     The laws of God peing perfect, are immutable, but no 
>     human law can be so considered.
> 
> Clearly tuples can be removed. They are garbage-collected like any other
> values in Python. If nothing else, you can turn the computer off, remove
> the RAM, grind it down into the finest powder, and scatter it to the winds.
> That surely is enough to remove the tuples <wink> 

Ok now rewrite that para above with 
s/tuple/numbers like 3 or 666/
So I put '3' on the ram and grind it to finest powder.
Have all trinities (of religious or secular variety) disappeared?
666 gone has the devil been banished from God's (or Steven's) universe?

> So according to Bouvier's definition, tuples are not immutable. But I trust
> that we can agree that Bouvier's definition is not useful here.

Actually its a very nice and apt quote.
Just add laws of mathematics to laws of God and it will be perfect.
[Or better remember that for Plato they were the same]



More information about the Python-list mailing list