前回、クラスってこういうものって説明をしました。 今回はdef __init__(self, name) の部分について詳しくみていきます。 __init__() を使ってクラスの中で属性(nameとかageとか)を定義しておけば、 sing() メソッドの中でその属性が使えたはずだけど __init__() が ...
以前の記事で、Pythonでルーレット作成しました。 今日は作成に当たってpythonを使う中で、構文理解に時間がかかったselfやらinitをしっかり理解しようというモチベーションのもと、この記事を書いてます。やっぱ自分で説明しようとすると自分にも身に ...
In Python, instance initialization happens in the __init__ method. Generally speaking, you should keep as little logic as possible in it, and you should think about what the class needs and not how it ...