38
21

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

pythonでオブジェクトのクラスを調べる

Last updated at Posted at 2017-03-14

rubyで言うところの.classメソッドみたいなのが欲しい。

'Ruby'.class
# => String

なんらかのインスタンスがどのクラスから作られたものなのか確認したい。

'Python'.__class__.__name__
# => str

__class__を使えばクラスが取得できる。さらに__class__.__name__を使うとクラス名が取得できる。

38
21
1

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
38
21

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?