4 ms·
I've been a weirdo with my Python code recently, and tend towards a more functional programming style. So, the `operator` module is essential for doing some coo
by sdrabing 5y ago
I've been a weirdo with my Python code recently, and tend towards a more functional programming style. So, the `operator` module is essential for doing some cools things with maps.
For instance, I'm writing a library to simulate the behavior of vectors in R, and that means vectorized operators (the operators runs the length of two paired vectors). All you need to do is make a special tuple subclass that maps the operator along another tuple (vector) and returns your vector subclass:
https://github.com/shanedrabing/pyrat/blob/e0049213152f615e41f6d189560edc9317fd5fc1/pyrat/base.py#L523 https://github.com/shanedrabing/pyrat/blob/e0049213152f615e4...
Anyways, this is all to say that I love `operator` and try my best not to use lamdbas much anymore (except where they are honestly simpler).
- 6gvONxR4sf7o 5y agoI try that, but it makes tracebacks harder frequently. Adjusting my programming style based on error message availability is a pet peeve of mine.