On Fri, 13 Dec 2019 11:34:24 +0100
Antoon Pardon <antoon.par...@vub.be> wrote:

> Well if you really want to go this route, you may consider the
> following:
> 
> def branch4(a, b, z):
>     decision = [
>         ((lambda: a > 4 and b == 0), "first"),
>         ((lambda: len(z) < 2), "second"),
>         ((lambda: b + a == 10), "third")]
>     for test, result in decision:
>         if test(): return result

Nice. But as I've said before, in this case code legibility is more
important than out-clevering myself, so I'll stick with if/elif.
-- 
https://mail.python.org/mailman/listinfo/python-list

Reply via email to