Overload del operator on partial elements

Overload del operator on partial elements

__delitem__(self, key) is called when the del statement is called on a part of the object, and it should delete the element associated with key. Only mutable objects should define this method.

For a sequence, if the key is a negative integer, it should be used to count from the end. In other words, treat x[-n] the same as x[len(x)-n].





















Home »
  Python »
    Language Basics »




Python Basics
Operator
Statements
Function Definition
Class
Buildin Functions
Buildin Modules