❌ Five mistakes almost every Python developer makes once
1️⃣ Giving a function a default value that's a list or dictionary. This one is sneaky because it works in your first few tests and then quietly breaks the moment the function gets called more than once because that default gets created a single time, not fresh on every call, and it silently keeps growing in the background.
2️⃣ Creating a bunch of small functions inside a loop that each reference the loop variable
People expect each one to remember its "own" value from when it was created. They don't. They all end up referencing whatever the loop variable became by the time the loop finished, which is almost never what you wanted.
3️⃣ Comparing decimal numbers with a plain equals sign
Computers don't store decimal math with perfect precision, so two numbers that should obviously be equal sometimes aren't, according to the computer. There's a proper "close enough" comparison built for exactly this.
4️⃣ Confusing a quick copy with a real copy
A fast, shallow copy of something with nested lists or dictionaries inside still shares those inner pieces with the original change one, and you accidentally change both. A true independent copy needs a different approach entirely.
5️⃣ Catching every possible error with one generic catch-all
It feels protective in the moment, but it also hides real bugs behind the same wall as the error you actually expected, and you lose the ability to tell them apart.
None of these mean you're bad at this. Almost everyone hits each one exactly once, and then never forgets it.
Post #1248
848
- ❤ 4