[Python-Dev] Keyword for block statements

Ka-Ping Yee python-dev at zesty.ca
Sat Apr 30 09:44:20 CEST 2005

On Fri, 29 Apr 2005, Phillip J. Eby wrote:
> At 08:21 PM 4/29/05 -0500, Ka-Ping Yee wrote:
> >All the statements in Python are associated with keywords, except
> >for assignment, which is simple and extremely common.  I don't
> >think the block statement is simple enough or common enough for
> >that; its semantics are much too significant to be flagged only
> >by a little punctuation mark like a colon.
> Don't forget the 'as' clause.

It's optional, and you have to skip an arbitrarily long expression
to get to it.

> >if there is a distinctive keyword, a Python programmer who comes
> >across this unfamiliar construct will be able to ask someone
> >"What does this 'spam' keyword mean?" or can search on Google for
> >"Python spam" to find out what it means.  Without a keyword,
> >they're out of luck.  Names are power.
> help(synchronized) or help(retry) would doubtless display useful
> information.

The programmer who writes the function used to introduce a block
can hardly be relied upon to explain the language semantics.  We
don't expect the docstring of every class to repeat an explanation
of Python classes, for example.  The language reference manual is
for that; it's a different level of documentation.

> Conversely, try Googling for Python's "for" or "if" keywords,
> and see if you get anything useful -- I didn't.

I tried some of my favourite Python keywords :) and found that the
following searches all successfully turn up information on the
associated kinds of Python statements in the first couple of hits:

    python if
    python else
    python del
    python while
    python assert
    python yield
    python break
    python continue
    python pass
    python raise
    python try
    python finally
    python class
    python for statement
    python return statement
    python print statement

-- ?!ng

More information about the Python-Dev mailing list