Would be nice to have something like the Maybe-Monad in the functools package for example. Sometimes python's None is a valid output and can not be used equivalently to Nothing.
What I like to do is to break down my problem into only functions and then build up objects from them. This way I can reduce the tests around the object and easier test the functions.
I think you could have added, that map and filter return you a genrator. You wrap them in your examples in list( ... ) and get the same result as in the list comprehensions.
list( ... )
A cool thing to use is the operator module. Then you can do something like this:
from operator import add, mul
from functools import reduce
# => 10
# => 24
This reduces the amount of simple lambda functions like lambda x, y: x + y and makes the code more readable.
lambda x, y: x + y
We're a place where coders share, stay up-to-date and grow their careers.
We strive for transparency and don't collect excess data.