Python学习笔记

Python属性包装器

@property
def year(self):
return self._year;

@year.setter
def year(self, y):
self._year = y

Python工厂函数

@classmethod
def today(cls):
t = time.localtime()
return cls(t.tm_year, t.tm_mon, t.tm_mday)

 

Python获取所有属性

print cat.__dict__ 
posted @ 2017-08-03 00:22  涉谷猫猫  阅读(132)  评论(0)    收藏  举报