[Tutor] understanding pydoc try

Michael Janßen mi.janssen at gmail.com
Thu Aug 30 16:03:33 CEST 2012


On 30 August 2012 15:30, John Maclean <jayeola at gmail.com> wrote:

> What does the first line from `pydoc try` actually mean? This does not
> look like the syntax that one is supposed to use.
>
> try_stmt  ::= try1_stmt | try2_stmt
>

looks like part of the python language reference. It goes a little further
and explains what try1_stmt and try2_stmt actually suppose to mean:
http://docs.python.org/reference/compound_stmts.html#the-try-statement

try_stmt  ::=  try1_stmt | try2_stmt
try1_stmt ::=  "try" ":" suite
               ("except" [expression [("as" | ",") target]] ":" suite)+
               ["else" ":" suite]
               ["finally" ":" suite]
try2_stmt ::=  "try" ":" suite
               "finally" ":" suite

Let me try to rephrase it: "a try statement is either of
try-except-else-finally or of try-finally form".

This notation is used to formally describe language syntax:
http://docs.python.org/reference/introduction.html#notation

best,
Michael
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/tutor/attachments/20120830/0758c1ee/attachment.html>


More information about the Tutor mailing list