3 ms·
I am delighted every time the Python Standard Library is mentioned. Always has a nice surprise. The last time I was surprised was the itertools library.
by kumarvvr 5y ago
I am delighted every time the Python Standard Library is mentioned. Always has a nice surprise.
The last time I was surprised was the itertools library.
- lnyan 5y agoI feel the same way. Last week, I was surprised that `pow` in Python is actually a modpow: `pow(base, exp[, mod])`. Also check https://pymotw.com/3/ https://pymotw.com/3/. It's a great tour of the Python standard library
- hashmush 5y agoAnd since 3.8 the exponent can be negative, which lets you compute modular inverses without having to reimplement the extended Euclidean algorithm. >>> pow(5, -1, 13) 8 >>> 5 * 8 % 13 1
- jjice 5y agoHuh, it's the little things that are the neatest surpises. Having to write the EEA multiple times during my crypto class to do the homework was a real pain in the ass.
- magnio 5y agoIn case you haven't known this, check out data classes. It is so obvious yet so useful that I don't want to write Python lower than 3.7 anymore.
- nwomack 5y agoYes I agree, I also use typing.NamedTuple a lot
- nerdponx 5y agoWorthy of note: https://attrs.org https://attrs.org, which inspired dataclasses and has more features.
- leadingthenet 5y agoI’ll also plug one of my favourite python libraries: https://pydantic-docs.helpmanual.io/ https://pydantic-docs.helpmanual.io/