All values in Python are references. What you need to worry about is if a type is mutable. The basic numeric and string types, as well as tuple
and frozenset
are immutable; names that are bound to an object of one of those types can only be rebound, not mutated.
>>> t = 1, 2, 3
>>> t[1] = 42
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
TypeError: 'tuple' object does not support item assignment
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…