python byRef // copy

前端 未结 4 1600
花落未央
花落未央 2021-01-05 16:52

I am new to Python (and dont know much about programming anyway), but I remember reading that python generally does not copy values so any statement a = b makes b point to a

4条回答
  •  感情败类
    2021-01-05 17:30

    When you execute b = a, it makes b refer to the same value a refers to. Then when you execute a = 2, it makes a refer to a new value. b is unaffected.

    The rules about assignment in Python:

    1. Assignment simply makes the name refer to the value.

    2. Assignment to a name never affects other names that refer to the old value.

    3. Data is never copied implicitly.

提交回复
热议问题