"George Sakkis" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] | One of the few Python constructs that feels less elegant than | necessary to me is the del statement. For one thing, it is overloaded | to mean three different things: | (1) del x: Remove x from the current namespace | (2) del x[i]: Equivalent to x.__delitem__(i) | (3) del x.a: Equivalent to x.__delattr__('a') (or delattr(x,'a'))
Since I see del x.a as deleting a from the attribute namespace of x, I see this as the same meaning. A namespace is a specialized association (keys are identifier strings). A dict is more generalized (keys merely hashable). So ditto for del dic[key]. The only different meaning is del somelist[i]. The implicit association between counts in range(n=len(somelist)) *is* broken, but unless i == n-1, items are 'shifted down' so that some other item become associated with i, and j's for i < j < n-1 get new associations and n-1 is left with none. One could imagine del somelist[i] as simple leaving a void in the list. (Which is not to say that that would be terribly useful.) tjr -- http://mail.python.org/mailman/listinfo/python-list