Python – Get Object’s Class Name | Ridge Solutions, Ireland
2013-07-09 13:55
337 查看
Python – Get Object’s Class Name | Ridge Solutions, Ireland
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__
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__
相关文章推荐
- object_getClassName swift得到类名
- object_getClassName
- python get class base name
- object_getClassName swift得到类名
- 实现ES5以下兼容,Object.create()、getElementsByClassName()
- 黑马程序员-反射-.class-Class.forName()-object.getClass()-Constructor-Field
- object.className or object.getAttribute(“className/class”)?
- 那xxx.class.getName()為什麼能這樣寫?? 看了半天都快搞不清楚到底在程式中的example到底是class ? object ? 還是instance了
- getElementsByClassName简单实现
- 关于class.getResourceAsStream(String name)与 class.getClassLoader().getResourceAsStream(String name)的路径
- 制定document.getElementByClassName()
- AS3获取对象类名,getDefinitionByName,getQualifiedClassName,getQualifiedSuperclassName
- ie8兼容问题(一) getElementsByClassName
- 配置事务时报错java.lang.NoSuchMethodError: org.springframework.util.ClassUtils.getQualifiedMethodName(Ljava
- getClass().getName()再学习
- Python下Pip安装包下的AttributeError: 'Requirement' object has no attribute 'project_name'
- 推荐一个封装好的getElementsByClassName方法
- Python标准库:内置函数isinstance(object, classinfo)
- 类名.class, class.forName(), getClass()区别
- Class.getName和Class.getCanonicalName的区别