[Python-Dev] Re: anonymous blocks

Aahz aahz at pythoncraft.com
Tue Apr 26 21:02:56 CEST 2005

On Tue, Apr 26, 2005, Guido van Rossum wrote:
> Now there's one more twist, which you may or may not like.  Presumably
> (barring obfuscations or bugs) the handling of BreakFlow and
> ContinueFlow by an iterator (or generator) is consistent for all uses
> of that particular iterator.  For example synchronized(lock) and
> transactional(db) do not behave as loops, and forever() does.  Ditto
> for handling ReturnFlow.  This is why I've been thinking of leaving
> out the 'with' keyword: in your mind, these calls would become new
> statement types, even though the compiler sees them all the same:
>     synchronized(lock):
>         BLOCK
>     transactional(db):
>         BLOCK
>     forever():
>         BLOCK
>     opening(filename) as f:
>         BLOCK

That's precisely why I think we should keep the ``with``: the point of
Python is to have a restricted syntax and requiring a prefix for these
constructs makes it easier to read the code.  You'll soon start to gloss
over the ``with`` but it will be there as a marker for your subconscious.
Aahz (aahz at pythoncraft.com)           <*>         http://www.pythoncraft.com/

"It's 106 miles to Chicago.  We have a full tank of gas, a half-pack of
cigarettes, it's dark, and we're wearing sunglasses."  "Hit it."

More information about the Python-Dev mailing list