官术网_书友最值得收藏!

The nature of Python object references

In previous chapters we've already talked about and used "variables" in Python, but what exactly is a variable? Consider something as straightforward as assigning an integer to a variable:

>>> x = 1000

What's really happening when we do this? First, Python creates an int object  with a value of 1000. This object is anonymous in the sense that it doesn't, in and of itself, have a name (x or otherwise). It's simply an object allocated and tracked by the Python runtime system.

After creating the object, Python then creates an object reference with the name x and arranges for x to refer to the int(1000) object:

Figure 4.1:  Assign the name 'x' to an integer object with the value 1000
主站蜘蛛池模板: 获嘉县| 崇州市| 高要市| 库尔勒市| 天等县| 屏东县| 太仓市| 安化县| 巴彦淖尔市| 克东县| 朝阳区| 嘉禾县| 响水县| 安岳县| 黄陵县| 延吉市| 浦县| 潮州市| 松滋市| 慈利县| 河南省| 福建省| 六安市| 阜新市| 论坛| 尉犁县| 安化县| 宁蒗| 汕头市| 太谷县| 西藏| 丹江口市| 阿瓦提县| 白山市| 高淳县| 通州区| 巴青县| 永嘉县| 随州市| 汉沽区| 丹阳市|