It's listed as a compound statement [1]. I know we've gotten a bit off
the main topic here, but `with` was added as a new feature in Python
2.5 that required a `from __future__ import with_statement` to enable
it rather than adding a new keyword to a minor release of the
language. In 2.6 and above it is always enabled no matter what.

[1] https://docs.python.org/2/reference/compound_stmts.html#the-with-statement

On Tue, Nov 6, 2018 at 7:32 AM Fieck, Brennan <[email protected]> wrote:
>
> There's possibly a backport via `future` or `__future__`, but `with` is not 
> listed as a simple statement type for Python2 
> https://docs.python.org/2/reference/simple_stmts.html
> ________________________________________
> From: Rawlin Peters <[email protected]>
> Sent: Thursday, November 1, 2018 2:33 PM
> To: [email protected]
> Subject: Re: [EXTERNAL] Re: Python2 EoL
>
> On Thu, Nov 1, 2018 at 11:51 AM Fieck, Brennan
> <[email protected]> wrote:
> > For an example of the first part of that, look no further than the 
> > __enter__ and __exit__ methods I added a week or two ago in tosession.py - 
> > Python2 doesn't do anything special with these functions, but there's no 
> > restriction placed on those names either. In Python3 that will allow them 
> > to be used in a context-managed setting via the `with` statement.
>
> Those methods aren't special only in Python3; they have the same
> special meaning in Python2 that allows a class to be used as a context
> manager via the `with` keyword.

Reply via email to