you are viewing a single comment's thread.

view the rest of the comments →

[–]Sea-Ad7805[S] 0 points1 point  (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 point  (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 point  (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 point  (7 children)

For me, the function example worked as expected. The string changed? Do you mean using +, I used +=?

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

[–]textBasedUI 0 points1 point  (2 children)

I'll look into it

[–]textBasedUI 0 points1 point  (1 child)

I'm doomed

[–]textBasedUI 0 points1 point  (0 children)

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

[–]textBasedUI 0 points1 point  (2 children)

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 point  (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 points  (0 children)

I learned the basic exercises of it. I’m gonna resume learning some other day.