鱼C论坛

 找回密码
 立即注册
查看: 2583|回复: 2

45课课上代码问题

[复制链接]
发表于 2017-4-17 22:02:15 | 显示全部楼层 |阅读模式

马上注册,结交更多好友,享用更多功能^_^

您需要 登录 才可以下载或查看,没有账号?立即注册

x
  1. >>> class C:
  2.         def __getattribute__(self , name):
  3.                 print('getattribute')
  4.                 return super().__getattribute__(name)
  5.         def __getattr__(self , name):
  6.                 print('getattr')
  7.         def __setattr__(self , name , value):
  8.                 print('setattr')
  9.                 super().__setattr__(name , value)
  10.         def __delattr__(self , name):
  11.                 print('delattr')
  12.                 super().__delattr__(name)
  13. >>> c.x
  14. getattribute
  15. getattr
  16. >>> c.x = 1
  17. setattr
  18. >>> c.x
  19. getattribute
  20. 1
  21. >>> del c.x
  22. delattr
复制代码


这一段主要是想要说明什么?如何理解super().__getattribute__(name)?
小甲鱼最新课程 -> https://ilovefishc.com
回复

使用道具 举报

发表于 2017-4-19 10:36:21 | 显示全部楼层
首先你要理解
  1. super()
复制代码
小甲鱼最新课程 -> https://ilovefishc.com
回复 支持 反对

使用道具 举报

 楼主| 发表于 2017-4-21 21:45:06 | 显示全部楼层

所以这是理解为调用父类的__getattribute__(name)是吗?
小甲鱼最新课程 -> https://ilovefishc.com
回复 支持 反对

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

小黑屋|手机版|Archiver|鱼C工作室 ( 粤ICP备18085999号-1 | 粤公网安备 44051102000585号)

GMT+8, 2025-5-11 23:18

Powered by Discuz! X3.4

© 2001-2023 Discuz! Team.

快速回复 返回顶部 返回列表