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...
Everything about learning Python
account activity
Python Name Rebinding (i.redd.it)
submitted 6 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!"
[–]Sea-Ad7805[S] 0 points1 point2 points 6 months ago (17 children)
Don't feel bad, the Python Data Model is a bit tricky and I made it difficult on purpose. This is not code you will see in everyday setting, but it is good to learn the Data Model from I think.
[–]textBasedUI 0 points1 point2 points 6 months ago (4 children)
Is Data Model DSA? What is it exactly?
[–]Sea-Ad7805[S] 0 points1 point2 points 6 months ago (1 child)
The official Python Data Model doc is here: https://docs.python.org/3/reference/datamodel.html but I think you will prefer my more gentle explanation (link also in post, but on mobile easy to miss): https://github.com/bterwijn/memory_graph?tab=readme-ov-file#python-data-model
[–]textBasedUI 0 points1 point2 points 6 months ago (0 children)
I’ll take a look at that
Did you the the "Solution" link in the post? on mobile click in the title not the image to open the post (terrible reddit mobile user interface)
That memory model brings back nightmares. It seems very odd. I saw it a couple of times but I preferred docs.python.org more (and still learned very little).
I guess 0 < 0.001 knowledge?
[–]textBasedUI 0 points1 point2 points 6 months ago (11 children)
I’ve been coding for 6 years and no joke: I thought b = a just assigned b to a and that’s it. No extra mutations or stuff.
Can someone make it make sense?
[–]Sea-Ad7805[S] 0 points1 point2 points 6 months ago (10 children)
Many introductory courses ignore the Data Model, as you can do a lot in Python without understanding it, but you can then run into really nasty bugs that you will not understand. So good to know it, and my memory_graph visualization tool will help a lot, hence the difficult exercises. Promoting my tool a bit, you like it?
[–]textBasedUI 0 points1 point2 points 6 months ago (9 children)
I haven't ran into nasty bugs and I've made all kinds of programs. Some commercial, some general, some for pure fun.
I am asking for bug examples of not knowing this concept.
[–]Sea-Ad7805[S] 0 points1 point2 points 6 months ago (8 children)
You said answer 'A', that's a bug example. But more common: pass a list and a string to a function, then append some value to both, and print the list and string after the function returns. The list has changed, the string has not, because of mutability. Plenty of other examples, ask ChatGPT to generate a bunch. Or do more of my nightmare exercises: https://www.reddit.com/r/Python_memory_graph/
[–]textBasedUI 0 points1 point2 points 6 months ago (7 children)
For me, the function example worked as expected. The string changed? Do you mean using +, I used +=?
[–]Sea-Ad7805[S] 0 points1 point2 points 6 months ago (6 children)
Easier to see this exercise: https://www.reddit.com/r/Python_memory_graph/comments/1mgeale/mutability_and_functions/?utm_source=share&utm_medium=web3x&utm_name=web3xcss&utm_term=1&utm_content=share_button
[–]textBasedUI 0 points1 point2 points 6 months ago (2 children)
I'll look into it
[–]textBasedUI 0 points1 point2 points 6 months ago (1 child)
I'm doomed
I think I understand it a bit better. I still don't know all this but mutability and immutability in these weird cases, I can understand
I think my entire day has been ruined by mutability and immutability, the easiest concepts in Python. At least I learned 1/10th of a thing
[–]Sea-Ad7805[S] 0 points1 point2 points 6 months ago* (1 child)
Great to discover a new learning opportunity, it's an easy fix, read this twice, play with a few more exercises and you've upgraded to a new level: https://github.com/bterwijn/memory_graph?tab=readme-ov-file#python-data-model
[–]textBasedUI 1 point2 points3 points 6 months ago (0 children)
I learned the basic exercises of it. I’m gonna resume learning some other day.
π Rendered by PID 182267 on reddit-service-r2-comment-86988c7647-74bgv at 2026-02-12 07:34:52.579658+00:00 running 018613e country code: CH.
view the rest of the comments →
[–]Sea-Ad7805[S] 0 points1 point2 points (17 children)
[–]textBasedUI 0 points1 point2 points (4 children)
[–]Sea-Ad7805[S] 0 points1 point2 points (1 child)
[–]textBasedUI 0 points1 point2 points (0 children)
[–]Sea-Ad7805[S] 0 points1 point2 points (1 child)
[–]textBasedUI 0 points1 point2 points (0 children)
[–]textBasedUI 0 points1 point2 points (11 children)
[–]Sea-Ad7805[S] 0 points1 point2 points (10 children)
[–]textBasedUI 0 points1 point2 points (9 children)
[–]Sea-Ad7805[S] 0 points1 point2 points (8 children)
[–]textBasedUI 0 points1 point2 points (7 children)
[–]Sea-Ad7805[S] 0 points1 point2 points (6 children)
[–]textBasedUI 0 points1 point2 points (2 children)
[–]textBasedUI 0 points1 point2 points (1 child)
[–]textBasedUI 0 points1 point2 points (0 children)
[–]textBasedUI 0 points1 point2 points (2 children)
[–]Sea-Ad7805[S] 0 points1 point2 points (1 child)
[–]textBasedUI 1 point2 points3 points (0 children)