3 (Not So) Pythonic Ways to Define a Function in One Line [for Hackers]
Summary: The most Pythonic way to define a function in a single line is to (1) create an anonymous lambda function and (2) assign the function object to a variable name. You can then call the function by name just like any other regularly-defined function. For example, the statement f = lambda x: x+1 creates … Read more