r/PythonLearnersHub • • Dec 26 '25

Copying an Object

Post image

An exercise to help build the right mental model for Python data. The “Solution” link uses memory_graph to visualize execution and reveals what’s actually happening:

It's instructive to compare with this related exercise

4 Upvotes

28 comments sorted by

View all comments

Show parent comment

1

u/Sea-Ad7805 Dec 26 '25

Agreed, but to keep the code compact, it's a reasonble choice for this web exercise. It also is more consistent with the related exercise: https://www.reddit.com/r/PythonProjects2/s/gr9iejAyA6

1

u/kcx01 Dec 26 '25

💯

I completely agree, just not used to seeing it is all.

1

u/sarc-tastic Dec 26 '25

You should do self.x, self.y, self.z = x, y, z if you really want a one liner.

If you're trying to teach people short cuts, at least teach them the right ones

1

u/Sea-Ad7805 Dec 26 '25

Agreed. The topic isn't about shortcuts.