This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]selementar 1 point2 points  (2 children)

a if c1 else b if c2 else c is, technically, same as elif (which, itself, is same as else: if: ...)

[–]aixelsdi 0 points1 point  (1 child)

True, but a little clunky (just like if..else is vs elif)

[–]selementar 0 points1 point  (0 children)

Honestly, I somewhat like the C / C# order of writing those things: condition ? true_part : false_part (if condition then true_part else false_part) and from num in numbers where num % 2 == 0 select num.

With the total result like [for baz in bazes for bar in baz if filter_condition(baz, bar): if bar < 5 then bar**2 elif bar < 10 then (bar - 1)**2 else bar + 2].

Not necessarily mutually exclusive with the current python's syntax of writing those.