(no title)
judicious | 1 year ago
Another module that's packaged with the stdlib that's immensely useful is itertools. I especially find takewhile, cycle, and chain to be incredibly useful building blocks for list-related functions. I highly recommend a quick read.
EDIT: functools is also great! Fantastic module for higher-order functions on callable objects.
sevensor|1 year ago
sgarland|1 year ago
[0]: https://docs.python.org/3/library/collections.html#collectio...
est|1 year ago
gcr|1 year ago
BerislavLopac|1 year ago
stevesimmons|1 year ago
The docs are here [0].
Some simple motivating applications:
- Look up names in Python locals before globals before built-in functions: `pylookup = ChainMap(locals(), globals(), vars(builtins))`
- Get config variables from various sources in priority order: `var_map = ChainMap(command_line_args, os.environ, defaults)`
- Simulate layered filesystems
- etc
[0] https://docs.python.org/3/library/collections.html#collectio...
matsemann|1 year ago
Just as recent as today I went to Kotlin to process something semicomplex even though we're a python shop, just because I wanted to bash my head in after a few attempts in python. A DS could probably solve it minutes with pandas or something, but again stringly typed and lots of guesswork.
(It was actually a friendly algorithmic competition at work, I won, and even found a bug in the organizer's code that went undetected exactly because of this)
judicious|1 year ago
daniel_grady|1 year ago
https://toolz.readthedocs.io/en/latest/
padthai|1 year ago
Flimm|1 year ago
d0mine|1 year ago
heavyset_go|1 year ago
judicious|1 year ago
mturmon|1 year ago
Another related tool is Counter (https://docs.python.org/3/library/collections.html#collectio...)
mont_tag|1 year ago
tpoacher|1 year ago