+ 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.
3 Answers
+ 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.
+ 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.
+ 1
David Carroll Great analysis š