- The Python Apprentice
- Robert Smallshire Austin Bingham
- 130字
- 2021-07-02 22:17:02
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
推薦閱讀
- 深入理解Bootstrap
- Microsoft Application Virtualization Cookbook
- 軟件架構設計:大型網站技術架構與業務架構融合之道
- Microsoft Dynamics 365 Extensions Cookbook
- JavaScript+Vue+React全程實例
- Mastering Rust
- Python機器學習:手把手教你掌握150個精彩案例(微課視頻版)
- Instant jQuery Boilerplate for Plugins
- AI自動化測試:技術原理、平臺搭建與工程實踐
- The Statistics and Calculus with Python Workshop
- Mastering SciPy
- Java Hibernate Cookbook
- PHP項目開發全程實錄(第4版)
- Responsive Web Design with jQuery
- Learning ROS for Robotics Programming