Tuples and immutability

Mark H. Harris harrismh777 at gmail.com
Sat Mar 1 01:16:24 EST 2014


On Friday, February 28, 2014 11:16:18 PM UTC-6, Ian wrote:

> How would you propose doing that?  Bear in mind that while Python
> knows that tuples specifically are immutable, it doesn't generally
> know whether a type is immutable.  


hi Ian,   consider the problem... its a "cake" and "eat it too" scenario...   you can't have your cake and eat it too....

This is what I mean...   the error message is telling the user that it cannot do what he has requested, and yet IT DID.  You have one of two scenarios:   1) the message is arbitrarily lying and it really can assign an immutable's item...  (and it did!)  or 2)  It really should NOT assign an immutables item (the message is truth) but the action was "allowed" anyway despite the protocol and accepted policy...  in which case the two scenarios add up to a giant logical inconsistency...  QED   a bug.

There really is no way to get around this from the average user's perspective. And therefore, this is going to come up again and again and again... because coders don't like unexpected logical inconsistencies.

It is not helpful either to explain it away by knowing how the policy works under the covers... the average user of the python language should not have to understand the policy of the underlying substructure... 

1) either they can't assign the list item of an immutable tuple type (and the action is a flaw, say bug

of

2) they really CAN set the immutable's list item type (which it did!) and the message is bogus.


Its one way or the other....  we can't have our cake and eat it too... this is (one way or the other) a bug.

IMHO



More information about the Python-list mailing list