>>> class CObj(object):
... pass
...
>>> dir()
['CObj', '__builtins__', '__doc__', '__loader__', '__name__', '__package__', '__spec__']
>>> cob = CObj
>>> dir()
['CObj', '__builtins__', '__doc__', '__loader__', '__name__', '__package__', '__spec__', 'cob']

>>> help(__name__)
Help on module __main__:

NAME
__main__

CLASSES
builtins.object
CObj

class CObj(builtins.object)
| Data descriptors defined here:
|
| __dict__
| dictionary for instance variables (if defined)
|
| __weakref__
| list of weak references to the object (if defined)

cob = class CObj(builtins.object)
| Data descriptors defined here:
|
| __dict__
| dictionary for instance variables (if defined)
|
| __weakref__
| list of weak references to the object (if defined)

FILE
(built-in)

>>> cins = cob()
>>> cins
<__main__.CObj object at 0x0000000000B5CC88>
>>> cins2 = CObj()
>>> cins2
<__main__.CObj object at 0x00000000013F5E10>
>>> CObj.x1 = 20
>>> cins
<__main__.CObj object at 0x0000000000B5CC88>
>>> cins.x1
20
>>> cins2.x1
20
>>> cins2.y1=30
>>> cins.y1
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
AttributeError: 'CObj' object has no attribute 'y1'
>>> CObj.y1
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
AttributeError: type object 'CObj' has no attribute 'y1'
>>> dir(cins)
['__class__', '__delattr__', '__dict__', '__dir__', '__doc__', '__eq__', '__format__', '__ge__', '__getattribute__', '__
gt__', '__hash__', '__init__', '__le__', '__lt__', '__module__', '__ne__', '__new__', '__reduce__', '__reduce_ex__', '__
repr__', '__setattr__', '__sizeof__', '__str__', '__subclasshook__', '__weakref__', 'x1']
>>> dir(cins2)
['__class__', '__delattr__', '__dict__', '__dir__', '__doc__', '__eq__', '__format__', '__ge__', '__getattribute__', '__
gt__', '__hash__', '__init__', '__le__', '__lt__', '__module__', '__ne__', '__new__', '__reduce__', '__reduce_ex__', '__
repr__', '__setattr__', '__sizeof__', '__str__', '__subclasshook__', '__weakref__', 'x1', 'y1']
>>> dir(cob)
['__class__', '__delattr__', '__dict__', '__dir__', '__doc__', '__eq__', '__format__', '__ge__', '__getattribute__', '__
gt__', '__hash__', '__init__', '__le__', '__lt__', '__module__', '__ne__', '__new__', '__reduce__', '__reduce_ex__', '__
repr__', '__setattr__', '__sizeof__', '__str__', '__subclasshook__', '__weakref__', 'x1']
>>> dir(CObj)
['__class__', '__delattr__', '__dict__', '__dir__', '__doc__', '__eq__', '__format__', '__ge__', '__getattribute__', '__
gt__', '__hash__', '__init__', '__le__', '__lt__', '__module__', '__ne__', '__new__', '__reduce__', '__reduce_ex__', '__
repr__', '__setattr__', '__sizeof__', '__str__', '__subclasshook__', '__weakref__', 'x1']
>>>

>>> hasattr(CObj, x1)
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
NameError: name 'x1' is not defined
>>> hasattr(CObj, 'x1')
True
>>> hasattr(CObj, 'y1')
False
>>> hasattr(CObj, 'y1')

最新文章

  1. r.js结合gulp等于webpack(angular为例)
  2. SignalR 2.1 简单入门项目
  3. 2016年12月27日 星期二 --出埃及记 Exodus 21:22
  4. proteus汉化
  5. 【matlab】输出固定位数的数字
  6. Linux命令入门
  7. 使用dynamic获取类型可变的json对象
  8. ViewModel在MVC3中的应用:一个view显示多个model
  9. SHOW SLAVE STATUS几个常见参数
  10. Windows完成端口网络模型
  11. html+css学习笔记 2[标签]
  12. JavaScript console 用法大全
  13. Angulajs 表单的ng-model绑定
  14. Qt 之 入门例程(二)
  15. 记一次wiki数据爬取过程
  16. MySQL暴错注入方法
  17. java 开发 websocket 网页端聊天室
  18. 使用BizTalk实现RosettaNet B2B So Easy
  19. golang &quot;text/template&quot; 模板语法简明教程
  20. iOS 3DTouch

热门文章

  1. go interface
  2. mac mysql5.7重置root密码
  3. 【WCF】wcf不支持的返回类型
  4. APP逆向常识
  5. Hibernate+EhCache配置二级缓存
  6. MySQL性能优化
  7. vue.js 第二课
  8. Markdown语法
  9. Java Win自动环境配置脚本
  10. iframe高度根据内容变化