标签:foo less mtu you change this diff color min
In this lesson, you will learn what mutable and immutable objects are, and the difference between them. This understanding will help you determine when objects can be modified in place, and when new objects must be created.
List is mutable, which means everytime it returns the same id whether or not you have changed it:
foo = [] id(foo) // same foo.append(3) id(foo) // same
Immtuable such as string:
str = "Hello" id(str) // not the same str = "World" id(str) // not the same
[Python] Understand Mutable vs. Immutable objects in Python
标签:foo less mtu you change this diff color min
原文地址:http://www.cnblogs.com/Answer1215/p/8012188.html