0

Python mutable and immutable objects

How does this mutable and immutable things works? Because here in Python every variable can be reassigned! Thanks L.

22nd Dec 2016, 12:48 PM
luca manzi
luca manzi - avatar
1 Answer
+ 2
An object is mutable if and only if there is at least one elementary operation over that object that *changes* the object. For instance the methods append, sort and reverse on the lists. These change the list without recreating the list (and they return None) However, the string methods (lower, upper, strip...) recreate the modified string and return it.
22nd Dec 2016, 3:02 PM
Amaras A
Amaras A - avatar