[Python-Dev] Extended Function syntax

Paul Moore lists@morpheus.demon.co.uk
Mon, 03 Feb 2003 21:05:27 +0000


Oren Tirosh <oren-py-d@hishome.net> writes:

> I agree. I don't see anything wrong with
>
> f=open('spam', 'r')
> with autoclose(f):
>    ...

I *like* this way of doing autoclose files. Much better than the way
I've been thinking

    f = autocloser("spam")
    with f:
        ...

> and I think that 
>
> with autolock(obj):
>    ...
>
> looks better than any other alternative proposed so far.

On the other hand, I quite like

    with lock:
        ...

(where lock is defined appropriately).

I don't know. Does the fact that the same statement is best used in
two subtly different ways (permanent object vs throwaway helper
object) count as a disadvantage of the statement (in terms of
teachability, if nothing else...)?

Sigh. I'm *so* glad I'm just skimming the thunk discussion - I don't
think my brain would survive the details :-)

Paul.
-- 
This signature intentionally left blank