Conditional operator in Python?

Fredrik Lundh fredrik at pythonware.com
Sun Apr 1 08:52:15 EDT 2001


Lloyd Hugh Allen wrote:
> Umm...there's a good argument for using it in "Dive into Python"
> <http://diveintopython.org/apihelper_andor.html>, that you can use
> conditionals in a lambda where an <if...> is not allowed.

to me, that sounds like a good argument not to use lambdas
in that situation...

here's the eff-bot's favourite lambda refactoring rule:

1) write a lambda function
2) write a comment explaining what the heck that lambda does
3) study the comment for a while, and think of a name that captures
   the essence of the comment
4) convert the lambda to a def statement, using that name
5) remove the comment

Cheers /F





More information about the Python-list mailing list