Addressing the last element of a list
Donn Cave
donn at drizzle.com
Thu Nov 10 01:47:41 EST 2005
More information about the Python-list mailing list
Thu Nov 10 01:47:41 EST 2005
- Previous message (by thread): Addressing the last element of a list
- Next message (by thread): Addressing the last element of a list
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Quoth Steven D'Aprano <steve at REMOVETHIScyber.com.au>: ... | So when working with ints, strs or other immutable objects, you aren't | modifying the objects in place, you are rebinding the name to another | object: | | py> spam = "a tasty meat-like food" | py> alias = spam # both names point to the same str object | py> spam = "spam spam spam spam" # rebinds name to new str object | py> print spam, alias | 'spam spam spam spam' 'a tasty meat-like food' The semantics of assignment are like that, period. If the right hand side is an int, a string, a class instance, a list, whatever, doesn't matter at all. The question of mutability at this point can be a red herring for someone who doesn't already understand these matters. Mutability is nothing special, it's just a feature built into the object type -- in general, the ability to store some state. This is of course useful in situations where we want to propagate state changes, so it naturally comes up in this context, but language per se does not observe any distinction here so far as I know. Donn Cave, donn at drizzle.
- Previous message (by thread): Addressing the last element of a list
- Next message (by thread): Addressing the last element of a list
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
More information about the Python-list mailing list