Fully Bracketed Syntax

Tim Peters tim_one at email.msn.com
Sat Feb 12 23:26:23 EST 2000

[Dennis Lee Bieber]
> ...
> 	I don't mind the use of ";" so much as the inconsistent usage
> of it... Most languages use it as a statement terminator, but then
> you hit Pascal (and Python, I fear) where it is used as a statement
> separator.

The only appearance of semicolon in Python's formal grammar is here:

    simple_stmt: small_stmt (';' small_stmt)* [';'] NEWLINE

So it's neither purely terminator nor purely separator -- but can be used as
either, or left out entirely if (as is almost always the best idea) you
never stuff more than one stmt on a physical line.

Note, however, that adjacent semicolons are not allowed!

>>> i=1;;
SyntaxError: invalid syntax

So there is no sense in which a trailing semicolon implies a "null stmt", or
other similar fiction.  The only null stmt in Python is the explicit "pass".

    y'rs  - tim

More information about the Python-list mailing list