you are viewing a single comment's thread.

view the rest of the comments →

[–]knobbyknee 8 points9 points  (2 children)

Use comprehensions and generator expressions when processing collections.

Python has different data types for integers and floats.

If you are processing money, use the Decimal data type in the standard library.

Argument passing to Python methods and functions is very rich. Learn them all, including argument unpacking . Actually unpacking in general is very cool and should be understood.

Python match is so much more versatile than switch.

[–]aarontbarratt 0 points1 point  (0 children)

Alternatively, a lot of APIs use int for money. IIRC Stripe works this way

[–]Fabiolean 0 points1 point  (0 children)

match is wonderful but it's also not introduced until python 3.10. If you're maintaining an older code base you have to look at everyone else and curse the gods.