r/learnpython • • 1d ago

What's one Python mistake you made when you were starting out that you still remember?

Something I've noticed while learning Python is that writing my own code sometimes feels easier than reading code written by someone else.

When I write a program, I know what each variable and function is supposed to do. But when I open an unfamiliar project, understanding the flow, function calls, dependencies and overall structure can take much longer.

I think reading existing code is an important skill that deserves as much attention as writing code.

It's an interesting part of becoming a better developer.

3 Upvotes

7 comments sorted by

3

u/supercoach 21h ago

Probably the biggest mistake I made was thinking that the target variable name used in for loops was some magic word that changed how the loop worked.

I didn't understand iterators, so when I saw someone write for key, value in dict I thought some sort of wizardry was taking place and that changing the value(s) after for would change the behaviour of the loop.

1

u/Mathie1729 1h ago

Definitely the mutable list aliasing thing. Did list2 = list1, mutated list2, and list1 changed too. I was convinced the interpreter was broken until I printed the ids. That one really stuck.

•

u/Baner-Fournadet 50m ago

yeah tutorials using the exact same placeholder names every single time really doesnt help with that

1

u/Sanduhstorm 19h ago

Probably not leaving comments in my code. Not a syntax issue but more of a general one

1

u/copperfoxtech 14h ago

Biggest mistake was thinking a self taught backend developer could get a job, does that count? Lol.

To answer your question more seriously, I would say the scale of projects I was choosing to build myself at certain stages of my learning journey

1

u/iGamingTools 9h ago

mutable default args. def add(item, items=[]) and then spending an hour on why the list kept growing between calls. the default is created once when the function is defined, so every call shares it. items=None and creating the list inside is the fix