Extracting elements over multiple lists?

Steven D'Aprano steve+comp.lang.python at pearwood.info
Tue Nov 15 17:25:16 EST 2011


On Wed, 16 Nov 2011 06:53:26 +1100, Chris Angelico wrote:

> On Wed, Nov 16, 2011 at 5:17 AM, Dave Angel <d at davea.name> wrote:
>> a = someexpression...
>> b = a
>> ....
>> del a
>>
>> Does not (necessarily) delete the object that a refers to.  It merely
>> deletes the symbol a.
> 
> I'd have to classify that as part of the change of thinking necessary
> for a refcounted language, and not specific to del at all. 

Languages aren't refcounted. Or at least, *Python* isn't a refcounted 
language. CPython is a refcounted implementation. IronPython and Jython 
are not. del behaves exactly the same in IronPython and Jython as it does 
in CPython: it removes the name, which may have a side-effect of deleting 
the object.


> The del
> statement is identical to "a = None" in terms of deleting objects;

I'm not entirely sure what you arr trying to say here. I *think* you are 
trying to say is this:

    Given that `a` is bound to my_object initially, `del a` 
    from the point of view of my_object is no different 
    from re-binding a to some other object such as None 
    (or any other object).

which is true as far as it goes, but it fails to note that the name "a" 
no longer exists after `del a` while it does exist after `a = None`.


-- 
Steven



More information about the Python-list mailing list