# 先回顾一下
class Room:
def __init__(self,name,width,length):
self.name = name
self.width = width
self.length = length
@property
def area(self):
return self.width * self.length
r1 = Room('wang',100,100)
print(r1.area) class Lazyproperty:
def __init__(self,func):
self.func = func
def __get__(self,instance,owner):
print("我们自己定义的属性")
if instance is None:
return self
return self.func(instance)
class Room:
def __init__(self,name,width,length):
self.name = name
self.width = width
self.length = length
@Lazyproperty
# area = Lazyproperty(area)
# 现在area是一个类,而不是函数
def area(self):
# print(self.area)
return self.width * self.length
r1=Room('alex',1,1)
print(r1.area)

最新文章

  1. Windows下搭建Wordpress博客网站
  2. 【QUESTION】
  3. solr 3.5.0 与 tomcat 7.0.5 整合配置
  4. Microsoft Naive Bayes 算法——三国人物身份划分
  5. 为什么是 Cloud Service?
  6. 你是否还在质疑EF的性能
  7. 必备的 Java 参考资源列表(转)
  8. Web前端相关
  9. dmucs与distcc
  10. 实体框架 (EF) 入门 => 二、在全新的数据库中使用 Code First
  11. HDU 1043 Eight (A* + HASH + 康托展开)
  12. google perftools分析程序性能
  13. Delphi下创建异形窗体
  14. BZOJ 1691: [Usaco2007 Dec]挑剔的美食家( 平衡树 )
  15. shell初学
  16. openfec的学习笔记
  17. [SQL]SQL 执行顺序
  18. python--递归(附利用栈和队列模拟递归)
  19. ****** 三十四 ******、软设笔记【存储器系统】-Cache存储器
  20. Python+OpenCV图像处理(十五)—— 圆检测

热门文章

  1. Ubuntu16.04连接SSH出现 Server responded “Algorithm negotiation failed” 的解决方法
  2. php类知识---命名空间
  3. Python之exec()/compile()方法使用
  4. keras手写数字识别
  5. 坚果Pro2刷魔趣系统教程,刷回锤子系统教程
  6. http状态码301和302详解及区别——辛酸的探索之路
  7. 五、在事务中使用Mybatis缓存的那些坑
  8. python-pandas-1
  9. vue的通信方式(二)---祖父孙三个级别的之间的隔代通信
  10. Access denied for user 'ODBC'@'localhost' (using password: NO) 的解决方法