python contextmanagers and ruby blocks

Aahz aahz at pythoncraft.com
Thu Mar 12 18:08:37 CET 2009


In article <c6b9e335-a04d-44cb-b18e-18a52eef1586 at k19g2000yqg.googlegroups.com>,
Alia K  <alia_khouri at yahoo.com> wrote:
>Aahz wrote:
>>
>> Longer answer: the way in Python to achieve the full power of Ruby
>> blocks is to write a function.
>
>You are most likely right... there is probably no need to introduce
>ruby-like blocks to python where iteration comes naturally with list
>comprehensions and generators. But for the simple case of entering a
>block of code as one does with @contextmanager I suppose it would be
>nice to make a generator with a single yield statement a
>contextmanager by default such that [...]

There has been some discussion of this on the python-ideas mailing list;
if this is a subject you care about, you may want to read up on the
history and join the list.
-- 
Aahz (aahz at pythoncraft.com)           <*>         http://www.pythoncraft.com/

"All problems in computer science can be solved by another level of     
indirection."  --Butler Lampson



More information about the Python-list mailing list