Searching equivalent to C++ RAII or deterministic destructors

Aahz aahz at
Sat Jul 4 00:50:47 EDT 2009

In article <ftps459nklqio3nghaaraniqo3fs9r8ck8 at>,
Tim Roberts  <timr at> wrote:
>Dave Angel <davea at> wrote:
>>You're right of course.  What I was trying to say was it deletes the 
>>reference to the object.  Unlike obj = None, del obj removes the 
>>reference (attribute) entirely. Although I don't know what it should be 
>>called if it's a local variable.  Perhaps it "unbinds" the name.
>Yes.  As far as the object is concerned, "obj = None" and "del obj" are
>exactly identical.  In both cases, there is one less binding to the name.
>The difference between the two is only whether the name lives on in the
>A local variable is (usually) just a name in the local() namespace.

OTOH, Python's ``del`` applies to targets generally, not just names:

>>> L = [1,2,3]
>>> del L[1]
>>> L
[1, 3]
Aahz (aahz at           <*>

"as long as we like the same operating system, things are cool." --piranha

More information about the Python-list mailing list