__init__ コンストラクタ。インスタンスを生成する際に呼び出される。 >>> class Hoge(object): ... def __init__(self, name): ... self.name = name ... >>> h = Hoge("John") >>> h.name 'John' __getitem__, __setitem__ 添字付きアクセスに対する[]演算子オーバーロード。添字でのアクセスが可能なオブジェクトになる。 >>> class MyList(object): ... def __getitem__(self, key): ... return key+10 ... def __setitem__(self, key, value): ... print "set {0}={1}".format(key, value) ... >>> ml =
![__xxx__ 形式の特殊メソッド、特殊フィールド](https://cdn-ak-scissors.b.st-hatena.com/image/square/7475bfcca0f7b67cba784a475a73bc7cf160f607/height=288;version=1;width=512/https%3A%2F%2Fpython.civic-apps.com%2Fwp-content%2Fuploads%2F2017%2F10%2Fcropped-siteicon-1.png)