Naming and Binding
A name is a piece of text that is bound to an object. They are a reference to an object. Examples are function names, class names, module names, variables, etc.
Note: Names cannot reference other names, and assignment never creates a copy.
x = 1 # x is bound to 1 y = x # y is bound to VALUE of x x = 2 # x is bound to 2 print(x, y) # 2 1
y = x, the name
yis being bound to the value of
yare the 'real' name. The object
1simply has multiple names. They are the exact same object.
Names are created in multiple ways
>>> x = 1 x ━━ 1 >>> y = x x ━━ 1 y ━━━┛ >>> x = 2 x ━━ 2 y ━━ 1
You might think that the only way to bind a name to an object is by using assignment, but that isn't the case. All of the following work exactly the same as assignment:
askeyword when used with
• formal parameters in function headers
There is also
del which has the purpose of unbinding a name.