LoginSignup
36
22

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__を使うとクラス名が取得できる。

36
22
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
36
22