Context without manager

Grant Edwards grant.b.edwards at gmail.com
Sun Nov 26 23:03:20 EST 2023


On 2023-11-27, Grant Edwards via Python-list <python-list at python.org> wrote:
> On 2023-11-26, Dieter Maurer via Python-list <python-list at python.org> wrote:
>
>> If you do not have this case (e.g. usually if you open the file
>> in a class's `__init__`), you do not use a context manager.
>
> He knows that. The OP wrote that he wants to use <something> that can
> _only_ be used by a context manager, but he wants that usage to be
> spread over various methods of a class he's writing.  So he's asking
> how to fool that <something> into working when he's not using a
> context manager.

I should probably have written "how to fool that <something> into
working when he's not using a 'with' statement"

--
Grant


More information about the Python-list mailing list