とある日に、「TypeError: ‘str’ object is not callable」というエラーにハマった(Python)
pythonの中でよくみる「def」から始まる塊について、用語が紛らわしいので整理する
def hoge(): # なんか処理書く
- Classの中の「def init()」 から始まるのは「Constractor(コンストラクター)」
- Classの中の「def」から始まるけど、Constractorではないのが「Method(メソッド)」
- Classの外の「def」から始まるのは「Function(関数)」
#!/usr/bin/env python # coding: utf-8 class Test(): def __init__(self): # Constractor # なんか処理書く def test(self): # Method # なんか処理書く def testtest(): # Function # なんか処理書く
参考リンク