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. 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> 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. In object-oriented programming circles, including Python, the relevant definition is that you cannot add or remove elements from the tuple once it is instantiated. That is all. If those elements happen to be mutable themselves, they don't cease to be mutable just because you happen to have put them in a tuple. This does not happen: mylist = [] mytuple = (None, 1, mylist) mylist.append(0) => raises an exception The *tuple* is immutable, not the list. The elements of the list are not elements of the tuple and don't participate in the guarantee of tuple-immutability. > As a parallel here is Dijkstra making fun of AI-ers use of the word > 'intelligent' > http://www.cs.utexas.edu/users/EWD/transcriptions/EWD06xx/EWD618.html Nice rant, but as is typical of so many rants by Dijkstra, it's overflowing with smugness at his own cleverness, and very light on actual reasoning or sense. -- Steven -- https://mail.python.org/mailman/listinfo/python-list