23
I was reading a beginner Python book and it said you can name a variable almost anything, but 'list' is a bad idea.
Found this out the hard way when my simple script broke because I named something 'list' and then tried to use the actual list() function later (oops).
2 comments
Log in to join the discussion
Log In2 Comments
riverm489d ago
Yeah, that's a classic beginner trap. I started keeping a little cheat sheet of those reserved words next to my monitor. It saves you from the weird bugs later when your code just stops making sense.
5
white.seth9d ago
Honestly the cheat sheet idea feels like a band-aid. Memorizing a list of reserved words is just busy work that doesn't really teach you why they're reserved. You learn them way faster by actually hitting the errors and having to debug it yourself. That struggle makes it stick.
9