python - Explain the code function in call by object -
how y equal x call object no function call how work how y value change
y = [1, 2, 3] x = y x[:] = [-1]*3 print y [-1, -1, -1]
please explain happen in x , y , call object
y = [1, 2, 3] x = y
x
, y
both point same list.
x[:] = [-1]*3
that list modified, way of assignment whole-object-slice (see here).
print y # [-1, -1, -1]
the modified list printed console.
and way: there no "call object". assignment slice (which, noted in link, modifies object).
Comments
Post a Comment