Python notes: mutable and immutable

来源:互联网 发布:9001端口局域网可访问 编辑:程序博客网 时间:2024/06/05 10:47
1. Objects are Python's abstraction for data.
2. Every object has an identity, a type and a value.
3. identity: is, id().
4. type() returns an object's type.
5. Objects whose value can change are said to be mutable.
6. Objects whose value is unchangeable once they are created are called immutable.
7. The value of an immutable container object that contains a reference to a
mutable object can change when the later's value is changed.
8. Numbers, strings and tuples are immutable, while dictionaries and lists are
mutable.

Python passes references-to-objects by value.
For detail, see pass by value
原创粉丝点击