When is semicolon use in Python considered “good” or “acceptable”?

PEP 8 is the official style guide and says:

Compound statements (multiple statements on the same line) are generally discouraged.

(See also the examples just after this in the PEP.)

While I don’t agree with everything PEP 8 says, if you’re looking for an authoritative source, that’s it. You should use multi-statement lines only as a last resort. (python -c is a good example of such a last resort, because you have no way to use actual linebreaks in that case.)

Leave a Comment