您的位置:首页 > 移动开发 > Objective-C

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

2013-07-09 13:55 337 查看
Python – Get Object’s Class Name | Ridge Solutions, Ireland

Python – Get Object’s Class Name

Author: Kevin GoddenJuly 26, 2011Q: 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__
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: