A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://mail.python.org/pipermail/python-dev/2003-February/032921.html below:

[Python-Dev] With statement

[Python-Dev] With statement [Python-Dev] With statementMoore, Paul Paul.Moore@atosorigin.com
Tue, 4 Feb 2003 16:45:28 -0000
From: Duncan Booth [mailto:duncan@rcp.co.uk]
> Your autoclose example doesn't use __enter__, and your autolock =
example=20
> would work just as well if you moved the __enter__ code into __init__=20
> (although then you couldn't write it the alternative way you suggest).

> Do you have any good examples that actually require __enter__, or =
could it=20
> be dropped for even more simplicity?

My actual preference is for a lock object with enter =3D acquire and
leave =3D release. Then, the idiom is

    with my_lock:
        # protected code

This requires a separate enter hook.

Paul.



RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4