24
Spent 5 months doing variables wrong in Python before a coworker saw my screen
I was using 'list' as a variable name everywhere in my scripts. Dude just said 'you know that overwrites the built-in function right?' and walked away. My loops were breaking for no reason I could figure out. Has anyone else had a basic mistake take way too long to catch?
2 comments
Log in to join the discussion
Log In2 Comments
the_avery14d agoMost Upvoted
Yeah, the "id" thing got me too. I used "id" as a variable name for a database script once and Python just kept throwing weird errors. Took me two days to figure out I was shadowing the built-in function. Now I always run a quick check for reserved words before naming anything.
6
clairebaker14d ago
My coworker caught me naming a variable 'id' and I had the same moment of pure embarrassment. Simple fix was just sticking to lowercase_with_underscores and using things like 'user_list' or 'item_id' instead of the generic names.
3