浙江省高等学校教师教育理论培训

微信搜索“毛凌志岗前心得”小程序

  博客园  :: 首页  :: 新随笔  :: 联系 :: 订阅 订阅  :: 管理

Python – Get Object’s Class Name | Ridge Solutions, Ireland

Q: How do I get a python object’s class name?

 

A: Use the object’s __class__ attribute and then get its __name__ attribute.

 

Another python introspection gem, to get an object’s class name just access its __class__ attribute, for example you can define a method to return the object’s name as follows:

def get_runtime_type_name(self):
  return self.__class__.__name__
posted on 2013-07-09 13:55  lexus  阅读(880)  评论(0编辑  收藏  举报