To become an effective Python programmer, it is crucial that you learn to draw the distinction between altering an object and assigning to a name, which previously happened to refer to the object. These two kinds of operations have nothing to do with each other. A statement such as
a = [] rebinds name
a but performs no alteration at all on the object that was previously bound to name
a. Therefore, the issue of references versus copies just doesn't arise in this case: the issue is meaningful only when you alter some object.
[Python]alter or assign an object
最新推荐文章于 2024-01-14 17:58:06 发布