3 ms·
1. Try teaching your students the standard notation for set building -- that's where it comes from, and it's useful outside of Python. https://en.wikipedia.org/
by empthought 9y ago
1. Try teaching your students the standard notation for set building -- that's where it comes from, and it's useful outside of Python. https://en.wikipedia.org/wiki/Set-builder_notation https://en.wikipedia.org/wiki/Set-builder_notation
2. They're all still there, but they're not as good as comprehension syntax.
3. Use type(self) unless you know why you'd want to use __class__ (Python 2 old-style classes).
4. That's legacy; probably if things were done from scratch today, they'd be Int, Str, Float. Back when the names were chosen there was a stricter line between builtins and unset-defined classes, and there was more consideration given to people migrating from C and C++.
5. Yes, luckily the .sort() method gives you at least some hint by not returning anything. It's a good application of command-query separation, but I forget it often myself.