[Python-ideas] PEP 505 (None coalescing operators) thoughts

Greg Ewing greg.ewing at canterbury.ac.nz
Tue Sep 29 07:55:44 CEST 2015


Guido van Rossum wrote:
> On Mon, Sep 28, 2015 at 12:47 PM, Andrew Barnert <abarnert at yahoo.com 
> <mailto:abarnert at yahoo.com>> wrote:
> 
>         Expr(
>             value=Attribute(
>                 value=Attribute(
>                     value=Name(id='spam'), attr='eggs', uptalk=True),
>                 attr='cheese', uptalk=False))
> 
> Hm, I think the problem is that this way of representing the tree 
> encourages thinking that each attribute (with or without ?) can be 
> treated on its own.

It's hard to think of any other way of representing this in
an AST that makes the short-circuiting behaviour any clearer.

I suspect that displaying an AST isn't really going to be
helpful as a way of documenting the semantics. Because the
semantics aren't really in the AST itself, they're in the
compiler code that interprets the AST.

-- 
Greg


More information about the Python-ideas mailing list