Fully Bracketed Syntax

Tim Peters tim_one at email.msn.com
Sun Feb 13 05:26:23 CET 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".

python-doesn't-take-stands-on-issues-that-don't-matter<wink>-ly
    y'rs  - tim






More information about the Python-list mailing list