PEP 679 -- Allow parentheses in assert statements

This is preposterous. The condition should not be evaluated at all if -O is given. If you want code that works with all Python versions you can write

assert long_condition, \
    long_message

or you can write

assert (
    long_condition
), (
    long_message
)

There is no need for temporary variables or for a Python version check.

(And don’t tell me “PEP 8 discourages backslashes”. It also says “When in doubt, you should use your best judgment.”)

2 Likes