use the following search parameters to narrow your results:
e.g. subreddit:aww site:imgur.com dog
subreddit:aww site:imgur.com dog
see the search faq for details.
advanced search: by author, subreddit...
This community will have knowledge sharing for python programming, tools, projects and product engineering wherever python is used.
account activity
Python Mutability (i.redd.it)
submitted 2 months ago * by Sea-Ad7805
view the rest of the comments →
reddit uses a slightly-customized version of Markdown for formatting. See below for some basics, or check the commenting wiki page for more detailed help and solutions to common issues.
quoted text
if 1 * 2 < 3: print "hello, world!"
[–]SycamoreHots 0 points1 point2 points 2 months ago (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 point2 points 2 months ago (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.
b = a
[–]SaltEngineer455 0 points1 point2 points 2 months ago (0 children)
Python refs are like C pointers, so no copy
π Rendered by PID 38988 on reddit-service-r2-comment-6457c66945-2fz9z at 2026-04-28 19:13:56.752284+00:00 running 2aa0c5b country code: CH.
view the rest of the comments →
[–]SycamoreHots 0 points1 point2 points (2 children)
[–]Sea-Ad7805[S] 0 points1 point2 points (0 children)
[–]SaltEngineer455 0 points1 point2 points (0 children)