Link Search Menu Expand Document

Magic Method

Table of contents


some magic methods

파이썬 더블 언더스코어: Magic Method

methodoperator(?)extranslate (roughly)
object.__getitem__(self, key)[]mylist[10]type(mylist).__getitem__(mylist, 10)
object.__setitem__(self, key, value)[]=mylist[10] = 1type(mylist).__setitem__(mylist, 10, 1)
object.__call__(self[, args...])()myfunc(arg1, arg2, ...)type(myfunc).__call__(myfunc, arg1, ...)