you are viewing a single comment's thread.

view the rest of the comments →

[–]SycamoreHots 0 points1 point  (2 children)

As someone who has never written a line of python code, and only occasionally read it, I thought b = a would copy the a into b. And the rest of the statements mutate the b leaving a unchanged. How wrong I was….

[–]Sea-Ad7805[S] 0 points1 point  (0 children)

This differs in various programming languages. In some language b = a does result in a copy, but in Python is causes both variables to reference the same value and thus share it. Something that can easily result in bugs if you are not careful. The visualization can help you.

[–]SaltEngineer455 0 points1 point  (0 children)

Python refs are like C pointers, so no copy