> For the complete documentation index, see [llms.txt](https://coding-girls-club.gitbook.io/python-turtle-tutorial/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://coding-girls-club.gitbook.io/python-turtle-tutorial/2-python-bian-cheng/2.5-zong-jie/2.5.1-zai-tan-python-dui-xiang.md).

# 2.5.1 再谈Python对象

**Learning By Reading 难度：★ 重要性：★★★★★**

* 观察结果，思考原因。

```python
a = [1, 2]
b = a
b += [3]
print(a)
```

* 不知道为什么？看[这里](https://www.zhihu.com/question/21000872/answer/16856382)。

**Learning By Thinking 难度：★ 重要性：★★★★★**

* 观察结果，思考原因。

```python
a = [1, 2]
b = a
b = b + [3]
print(a)
```

* 将程序稍微改写一下或许大家就能看出原因来。`b += [3]`等价于`b.__iadd__([3])`，

  `b = b + [3]`等价于`b = b.__add__([3])`。

  `__iadd__`改变了对象`b`（也就改变了`a`），`__add__`创造了一个新的对象。
* 试着用上文中画图的形式解释一下这段程序为什么会出现这样的结果。

**Learning By Reading 难度：★ 重要性：★★★★★**

* 观察结果，思考原因。

```python
a = 2
b = a
b += 1
print(a)
```

* 又和想象的不一样？看[这里](https://www.jianshu.com/p/c5582e23b26c)。
* `int`对象没有`__iadd__`方法，在`+=`的时候，Python会先查看对象有没有`__iadd__`方法，

  没有的话，就改用`__add__`。
