3 ms·
> But most "wtfpython" things don't actually affect people using the language Plenty do though. I've passed that page onto co-workers a lot, back when the lis
by Izkata 6y ago
> But most "wtfpython" things don't actually affect people using the language
Plenty do though. I've passed that page onto co-workers a lot, back when the list was smaller, and almost every time they've found something on the page that explains a bit of weirdness with Python that they'd just dismissed as buggy behavior and avoided touching.
The ones I remember them mentioning:
https://github.com/satwikkansal/wtfpython#-mutating-the-immutable https://github.com/satwikkansal/wtfpython#-mutating-the-immu...
https://github.com/satwikkansal/wtfpython#-beware-of-default-mutable-arguments https://github.com/satwikkansal/wtfpython#-beware-of-default...
And I multiple times I've had to explain the difference between references / shallow copy / deep copy to bootcampers, which falls under https://github.com/satwikkansal/wtfpython#-a-tic-tac-toe-where-x-wins-in-the-first-attempt https://github.com/satwikkansal/wtfpython#-a-tic-tac-toe-whe...
- andi999 6y agoShallow and deep copy is a surprising concept, but I think it is the core feature that actually allows python to handle large datasets.
- neolog 6y agoIMO those two gotchas (mutable default and late-binding closures) are actually the main ones. That's why they're mentioned explicitly here https://docs.python-guide.org/writing/gotchas/ https://docs.python-guide.org/writing/gotchas/ Shallow/deep copies is an unavoidable part of having mutable data. The main alternative way to handle mutation is a fancy type system like Rust's, which is not an acceptable tradeoff for new programmers.