Reference

A reference is a value that points to an object stored elsewhere in memory, rather than holding a copy of it. Two variables can reference the same object.

General Programming

When you assign an object to another variable, you often copy the reference, not the object — so changing it through one variable affects the other. This is the cause of many subtle bugs.

Examples

Python

a = [1, 2, 3]
b = a          # b references the same list
b.append(4)
print(a)

Output:

[1, 2, 3, 4]

See also

Back to the Dictionary