r/learnpython • u/DiwaharSec • 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.
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
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 dictI thought some sort of wizardry was taking place and that changing the value(s) afterforwould change the behaviour of the loop.