+ 1

In python, variables do not represent the portion of computer's memory where their value is written, but tags pointing to object

Please explain this.I don't get this line properly.

12th Jun 2020, 5:00 AM
Rajan K
Rajan K - avatar
3 ответов
+ 5
Rajan.K(ராஜ ராஜன் , ראג'ה ראג'אן ,Раджа Раджан) I think these links do a great job of explaining how variables in Python work differently from many other languages. https://realpython.com/python-variables/#object-references https://medium.com/@abdullah.tech/python-variables-are-pointers-c8b85880f21e https://jakevdp.github.io/WhirlwindTourOfPython/03-semantics-variables.html Consider the following line: i = 10 In many other languages, the value (10) is assigned to some memory address ( 0xF3 ) of the named variable ( i ). However, in Python, the following steps occur: 1. The value (10) is first assigned to some memory address ( 0x54 ) as a nameless object. 2. Then, the named variable ( i ) at memory address ( 0xF3 ) is assigned the reference value ( 0x54 ) instead of the value (10). So... i = 10 is essentially: 0x54 = 10 i at 0xF3 = 0x54 The variable ( i ) at 0xF3 is pointing to the object at 0x54 which contains the value 10. Hopefully, this makes sense.
12th Jun 2020, 9:48 AM
David Carroll
David Carroll - avatar
+ 1
Rajan.K(ராஜ ராஜன் , ראג'ה ראג'אן ,Раджа Раджан) I will try to write this in a different way. In python, variables do not represent the portion of computer memory where their value is written. In python, variables are but tags pointing to an object.
12th Jun 2020, 6:42 AM
Rik Wittkopp
Rik Wittkopp - avatar
+ 1
David Carroll Great analysis 👍
12th Jun 2020, 10:18 AM
Ore
Ore - avatar