Python之对象的属性

# -*- coding: utf-8 -*-
#python 27
#xiaodeng
#Python之对象的属性
#http://python.jobbole.com/82622/


#对象的属性

class bird():
    feather = True
 
class chicken(bird):
    fly = False
    def __init__(self,age):
        self.age = age


summer = chicken(2)
print(bird.__dict__)
print(chicken.__dict__)
print(summer.__dict__)
'''
{'__module__': '__main__', 'feather': True, '__doc__': None}
{'fly': False, '__module__': '__main__', '__doc__': None, '__init__': <function __init__ at 0x02042AB0>}
{'age': 2}
'''

 

posted @ 2015-11-06 23:22  Xiao|Deng  阅读(131)  评论(0编辑  收藏  举报