Context manager on method call from class

Joseph L. Casale jcasale at activenetwerx.com
Thu Mar 15 15:15:50 EDT 2018


From: Python-list <python-list-bounces+jcasale=activenetwerx.com at python.org> on behalf of Rob Gaddi <rgaddi at highlandtechnology.invalid>
Sent: Thursday, March 15, 2018 12:47 PM
To: python-list at python.org
Subject: Re: Context manager on method call from class
    
> from contextlib import contextmanager.
> 
> Then you just use the @contextmanager decorator on a function, have it 
> set up, yield the context you want, and clean up after.

Nice, all of what I wrote replaced with three lines:)

Thank you,
jlc


More information about the Python-list mailing list