Magic Method
Table of contents
some magic methods
method | operator(?) | ex | translate (roughly) |
---|---|---|---|
object.__getitem__(self, key) | [] | mylist[10] | type(mylist).__getitem__(mylist, 10) |
object.__setitem__(self, key, value) | []= | mylist[10] = 1 | type(mylist).__setitem__(mylist, 10, 1) |
object.__call__(self[, args...]) | () | myfunc(arg1, arg2, ...) | type(myfunc).__call__(myfunc, arg1, ...) |