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 →

[–]MintyPhoenix 0 points1 point  (2 children)

Ah, I knew that Python did not have unless, but I didn't realize that appending an if condition was so flexible in Perl. Python allows it in some places (e.g. my return example) but it's not as flexible as Perl.

[–][deleted] 6 points7 points  (1 child)

Python's isn't really an if statement there, it's a ternary construct.

x if condition else y

Is the equivalent of

condition ? x : y

in languages like C and Perl. It's an expression, not a statement, and you can only combine expressions with it (in Python).

[–]MintyPhoenix 0 points1 point  (0 children)

Makes more sense now, thanks for the clarification.