LoginSignup
2
0

Pythonでの「オブジェクト」、「インスタンス」、「クラス」の違い

Posted at

Pythonでの「オブジェクト」、「インスタンス」、「クラス」の違い

クラス (Class)
クラスは、オブジェクトの設計図またはテンプレートとして機能します。
クラスは属性(データ)メソッド(そのデータを操作する関数)を定義します。

オブジェクト (Object)
オブジェクトはPythonの基本単位で、データと機能性(メソッド)をカプセル化します。

インスタンス (Instance)
インスタンスはクラスから生成される具体的なオブジェクトです。

class Cat:
    pass

smallCat=Cat()

smallCatはCatクラスインスタンスであり、同時にPythonのオブジェクトです。

2
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
2
0