属性访问拦截器 

class Itcast(object):
def __init__(self,subject1):
self.subject1 = subject1
self.subject2 = "go"
#属性访问拦截器,打log
def __getattribute__(self, item):
print("---1>%s" %item)
if item == "subject1":
print("log subject1")
return 'redirect python'
else:
temp = object.__getattribute__(self,item)
print("---2>%s"%str(temp))
return temp
def show(self):
print("this is Itcast") s = Itcast("python")
print("--------1--------")
print(s.subject1)
print("--------2--------")
print(s.subject2)
print("--------3--------")
s.show()
print("--------4--------")

  输出

--------1--------
---1>subject1
log subject1
redirect python
--------2--------
---1>subject2
---2>go
go
--------3--------
---1>show
---2><bound method Itcast.show of <__main__.Itcast object at 0x000001F47161A860>>
this is Itcast
--------4--------

  

getattribute的更多相关文章

  1. request中getParameter和getAttribute的区别

    整理一下getParameter和getAttribute的区别和各自的使用范围. (1)HttpServletRequest类有setAttribute()方法,而没有setParameter()方 ...

  2. getAttribute、setAttribute、removeAttribute

    1.函数语法 elementNode.attributes:属性返回包含被选节点属性的 NamedNodeMap. elementNode.getAttribute(name):方法通过名称获取属性的 ...

  3. request:getParameter getAttribute

    转载自:http://www.cnblogs.com/shaohz2014/p/3804656.html 在浏览器地址输入,表示传入一个参数test,值为123 http://localhost:88 ...

  4. sizzle分析记录:getAttribute和getAttributeNode

    部分IE游览器下无法通过getAttribute取值? <form name="aaron"> <input type="text" name ...

  5. request属性 request.getAttribute()

    一.request.getParameter() 和request.getAttribute() 区别 (1)request.getParameter()取得是通过容器的实现来取得通过类似post,g ...

  6. request getParameter getAttribute

    在浏览器地址输入,表示传入一个参数test,值为123 http://localhost:8888/Test/index.jsp?test=123 在index.jsp中尝试使用EL表达式取出,代码如 ...

  7. setAttribute,,,getAttribute,,,,

    <!DOCTYPE html> <html> <head lang="en"> <meta charset="UTF-8&quo ...

  8. JQuery 1.8.3对IE9兼容问题getAttribute

    jQuery1.8.3在IE9下attr报错问题 jQuery1.8.3在IE9中attr方法保存. 解决方案如下: r = e.getAttribute(n); 修改为: r = e.getAttr ...

  9. getattribute()与getparameter()的区别

    1.它们取到的值不同.getAttribute取到的是对象(object),而getParameter取到的是String. 2.数据传递路劲不同.request.getParameter方法传递的数 ...

  10. 【JSP手记】--jsp里面session.getAttribute("×××")在java中的表示

    JSP里面的    <%=session.getAttribute("×××")%> 与java等价于         request.getSession().get ...

随机推荐

  1. html网页如何使用哪种浏览器内核渲染的选择

    众所周知,国内的浏览器基本都是双内核的(ie(Trident)+webkit):而且基本默认时都是用webkit内核.尽管IE浏览器体验差,但是有时也会需要用IE内核来渲染的(比如银行网站). 如果要 ...

  2. netty-socketio(一)之helloworld,与springboot整合

    netty-socketio是一个开源的Socket.io服务器端的一个java的实现, 它基于Netty框架. 1.参考资料 (1)netty-socketio项目github地址: https:/ ...

  3. Java中Annotation用法

    其他还可以参考的地址 https://www.cnblogs.com/skywang12345/p/3344137.html Annotation Annotation其实是代码里的特殊标记,这些标记 ...

  4. createDocumentFragment() 方法

    //createdocumentfragment()方法创建了一虚拟的节点对象,节点对象包含所有属性和方法. //当你想提取文档的一部分,改变,增加,或删除某些内容及插入到文档末尾可以使用create ...

  5. AVL平衡二叉树实现

    #include<stdio.h> #include<stdlib.h> #define TRUE 1 #define FALSE 0 #define EH 0 #define ...

  6. CopyOnWriteArrayList&Collections.synchronizedList()

    1.ArrayList ArrayList是非线性安全,此类的 iterator() 和 listIterator() 方法返回的迭代器是快速失败的:在创建迭代器之后,除非通过迭代器自身的 remov ...

  7. day16_python_1124

    圈子 圈子是互相影响,走着走着就散了. 道不同不相为谋,与人的认知相关. 圈子如何正向引导? 圈子能决定你的人生走向. 圈子能决定你的格局. 01 昨日内容回顾 序列化模块 将一个数据结构 ----& ...

  8. TCP/IP协议三次握手与四次握手

    TCP/IP协议三次握手与四次握手流程解析 一.TCP报文格式  TCP/IP协议的详细信息参看<TCP/IP协议详解>三卷本.下面是TCP报文格式图:图1 TCP报文格式  上图中有几个 ...

  9. java中的\b是什么意思?

    java中有2个地方有\b,一个是特殊字符\b,另一个是在正则表达式中表示边界的意思. 我们这里只讨论特殊字符\b 我这里一共接受到几种解释: 1.退格符相当于键盘上的Backspace符号 back ...

  10. Oracle物化视图梳理

    --物化视图可以分为三种类型:* 包含聚集的物化视图* 只包含连接的物化视图* 嵌套物化视图三种物化视图的快速刷新的限制条件有很大区别,而对于其他方面则区别不大. --物化视图创建方式(Build M ...