[Python-Dev] Multiline with statement line continuation

Steven D'Aprano steve at pearwood.info
Sat Aug 16 07:41:47 CEST 2014


On Fri, Aug 15, 2014 at 08:29:09PM -0700, Ethan Furman wrote:
> On 08/15/2014 08:08 PM, Steven D'Aprano wrote:

[...]
> >is a poor argument (that is, I'm disagreeing with it), since *single*
> >line parens-free with statements are already syntactically a tuple:
> >
> >     with spam, eggs, cheese:  # Commas make a tuple, not parens.
> 
> This point I do not understand -- commas /can/ create a tuple, but don't 
> /necessarily/ create a tuple.  So, semantically: no tuple.

Right! I think we are in agreement. It's not that with statements 
actually generate a tuple, but that they *look* like they include a 
tuple. That's what I meant by "syntactically a tuple", sorry if that was 
confusing. I didn't mean to suggest that Python necessarily builds a 
tuple of context managers.

If people were going to be prone to mistake

    with (a, b, c): ...

as including a tuple, they would have already mistaken:

    with a, b, c: ...

the same way. But they haven't.


-- 
Steven


More information about the Python-Dev mailing list