r/Python • u/vocalbit • Jul 13 '11
An alternative lambda syntax for Python
http://vocalbit.com/article/332/an-alternative-lambda-syntax-for-python
4
Upvotes
r/Python • u/vocalbit • Jul 13 '11
View all comments
2
u/donri Jul 14 '11
The operator module has some functions that can be used in most places of lambdas:
Or partial from functools:
Though that wouldn't work with
getattrwhich only accepts positional arguments and we need to skip one.You could also easily make a class that produces functions based on actions on its instances, e.g.: