Re:Python decorators they don't tell you about
by ivanjr0 on Sunday January 07, 2018 @12:24PM
(#16091615)
> Lambdas in Python are awkward
Can you elaborate on that, please?
Considering the examples given by the author, I think they would be a better option.
Re:Python decorators they don't tell you about
by abhirag on Sunday January 07, 2018 @12:32PM
(#16091663)
Not the OP but I think he was referring to the restrictions python puts on lambda expressions:
- they can only contain a single expression
- they cannot contain statements
Re:Python decorators they don't tell you about
by Sohcahtoa82 on Monday January 08, 2018 @08:17PM
(#16102620)
Python has lambdas that have multiple expressions and statements.
They're called functions.
Re:Python decorators they don't tell you about
by yen223 on Tuesday January 09, 2018 @03:40AM
(#16104536)
Python functions aren't anonymous
In fact, you could define a number of useful precondition functions in a single module and use them throughout a project. A couple of higher-order functions could make the post's examples safer and nicer-looking too. For example:
where the starts_with precondition is: