[Python-ideas] with-statement syntactic quirk

Barry Warsaw barry at python.org
Wed Oct 31 17:51:53 CET 2012


On Oct 31, 2012, at 09:55 PM, Nick Coghlan wrote:

>It's not an especially subtle corner of the grammar, it's
>tuples-as-context-managers (i.e. the case with no as clauses) that
>causes hassles:
>
>     with (cmA, cmB):
>           pass
>
>This is: a) useless (because tuples aren't context managers); but also
>b) legal syntax (it blows up at runtime, complaining about a missing
>__enter__ or __exit__ method rather than throwing SyntaxError at
>compile time)

So clearly we need to make tuples proper context managers <wink>.

-Barry
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 836 bytes
Desc: not available
URL: <http://mail.python.org/pipermail/python-ideas/attachments/20121031/055404fe/attachment.pgp>


More information about the Python-ideas mailing list