Statement local namespaces summary (was Re: python3: 'where' keyword)

Duncan Booth duncan.booth at invalid.invalid
Mon Jan 10 04:03:02 EST 2005


Nick Coghlan wrote:

> Grammar Change
> --------------
> Current::
>    statement ::=    stmt_list NEWLINE | compound_stmt
> 
> New::
>    statement ::=    (stmt_list NEWLINE | compound_stmt) [local_namespace]
>    local_namespace ::= "with" ":" suite
> 
> 
> Semantics
> ---------
> The code::
> 
><statement> with:
>     <suite>
> 
> translates to::
> 
> def unique_name():
>      <suite>
>      <statement>
> unique_name()
> 

Your proposed grammar change says that you need a newline after the 
statement:

    statement
    with:
        suite

e.g.

    res = [ f(i) for i in objects ]
    with:
        def f(x):
            pass

or

    for i in objects:
        f(i)
    with:
        def f(x):
           pass



More information about the Python-list mailing list