[Python-Dev] With statement (original) (raw)

Samuele Pedroni pedronis@bluewin.ch
Wed, 5 Feb 2003 18:16:14 +0100


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

> 2) Without the ability to define a scope at will, RAiI becomes less useful.

local f=open('sdaskdfjhaslk') ... del l Deleting this kind of variable (whether we call it local or something else) means you want its del executed now. It is also an assertion that its reference count is supposed to be 1 at this point. This not only gives you the ability to define a scope at will, it lets you create scopes dynamically. It's probably useful for more than just RAiI. Perhaps too useful.

it is not about variables, it is about objects, too much fragile magic

local f=open('sdaskdfjhaslk') w = f.write

w(...)

del f # ???