ch04
This commit is contained in:
@@ -0,0 +1,8 @@
|
||||
# key.points.mutable.assignment.py
|
||||
x = [1, 2, 3]
|
||||
def func(x):
|
||||
x[1] = 42 # this changes the original `x` argument!
|
||||
x = 'something else' # this points x to a new string object
|
||||
|
||||
func(x)
|
||||
print(x) # still prints: [1, 42, 3]
|
||||
Reference in New Issue
Block a user