Apa nama metode untuk menimpa []
operator (notasi subskrip) untuk kelas dengan Python?
python
operator-overloading
Sahas
sumber
sumber
__getslice__,
__setslice__` dan__delslice__' have been deprecated for the last few releases of ver 2.x (not sure exactly when), and are no longer supported in ver 3.x. Instead, use
__getitem__.
__setitem__` dan__delitem__' and test if the argument is of type
iris, i.e.:
jika isinstance (arg, slice): ...Anda mencari
__getitem__
metodenya. Lihat http://docs.python.org/reference/datamodel.html , bagian 3.4.6sumber