[Python-Dev] PEP 492 vs. PEP 3152, new round

Nick Coghlan ncoghlan at gmail.com
Sun Apr 26 07:23:04 CEST 2015


On 26 April 2015 at 06:18, Yury Selivanov <yselivanov.ml at gmail.com> wrote:
> Option #3. Create a new terminal for await expression between
> 'atom' and 'power'.
>
> Required grammar changes:
> https://gist.github.com/1st1/cb0bd257b04adb87e167#file-option-3-patch
>
> Repo to play with (parser module is broken atm):
> https://github.com/1st1/cpython/tree/await_noparens2
>
> Syntax:
>
>   await a()
>   res = await a() + await b()
>   res = await (await a()) # invalid syntax w/o parens
>   if await a(): pass
>   return await a()
>   print(await a())
>   func(arg=await a())
>   await (a() * b()) # w/o parens '(await a() * b())
>
> I think that Option #3 is a clear winner.

Very nice!

How would the following statements parse with this option?

    res = await a(), b()
    res = [await a(), b()]
    with await a(), b: pass
    f(await a(), b)

I think it's OK if these end up requiring parentheses in order to do
the right thing (as that will be helpful for humans regardless), but
the PEP should be clear as to whether or not they do:

    res = (await a()), b()
    res = [(await a()), b()]
    with (await a()), b: pass
    f((await a()), b)

Cheers,
Nick.

-- 
Nick Coghlan   |   ncoghlan at gmail.com   |   Brisbane, Australia


More information about the Python-Dev mailing list