Style question for conditional execution

Paul Rubin no.email at nospam.invalid
Wed Nov 24 15:43:18 EST 2010


Gerald Britton <gerald.britton at gmail.com> writes:
>     if v:
>         f()
>
> I might, however, think more in a functional-programming direction.
> Then I might write:
>
>     v and f()

Python has conditional expressions.  The above would be:

    f() if v else None

using "and" is bug-prone.



More information about the Python-list mailing list