インスタンス生成時に new は不要。 メソッドの第一引数には self を指定する(this の役割)。 文字列をクラス内にベタに定義すると、オブジェクトの説明を示す __doc__ 属性(docstring)になる。 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 #!/usr/bin/python # class Hoge: "Hoge is Test class." age = 19 def name(self): return "Hoge!" print "hello world" hoge = Hoge() print hoge.name() print hoge.age print hoge.\_\_doc\_\_ hello world Hoge! 19 Hoge is Test class. 参考 http://www.python.jp/doc/2.4/tut/node11.html http://www.shido.info/py/python7.html 追記 インデントは 4 スペースが慣例。 del で変数などを削除できる。 Python が見えてきた・・・、やっぱり色んな言語を知ることは世界観が広がっていいです。