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/2005-May/053648.html below:

[Python-Dev] Merging PEP 310 and PEP 340-redux?

[Python-Dev] Merging PEP 310 and PEP 340-redux? [Python-Dev] Merging PEP 310 and PEP 340-redux?Eric Nieuwland eric.nieuwland at xs4all.nl
Thu May 12 07:12:50 CEST 2005
Guido van Rossum wrote:
> class locking:
>     def __init__(self, lock): self.lock = lock
>     def __enter__(self): self.lock.acquire()
>     def __exit__(self, *args): self.lock.release()
>
> class opening:
>     def __init__(self, filename): self.filename = filename
>     def __enter__(self): self.f = open(self.filename); return self.f
>     def __exit__(self, *args): self.f.close()\
>
> And do EXPR as VAR: BLOCK would mentally be translated into
>
> itr = EXPR
> VAR = itr.__enter__()
> try: BLOCK
> finally: itr.__exit__(*sys.exc_info()) # Except sys.exc_info() isn't
> defined by finally

In this example locking's __enter__ does not return anything.
Would
do EXPR:
	BLOCK
also be legal syntax?


-eric

More information about the Python-Dev mailing list

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