属性访问拦截器 

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. sql server替换字段中的某个字符

    USE [Vocabulary ] GO --UPDATE [dbo].[table name] --   SET [en] = '' --      ,[cn] ='' -- WHERE --cha ...

  2. MySQL自增序列-亲试ok

    #1.创建sequence表,公共的 DROP TABLE IF EXISTS sequence; CREATE TABLE sequence (      name VARCHAR(30) NOT ...

  3. python 利用selectors实现异步I/O

    它的功能与linux的epoll,还是select模块,poll等类似:实现高效的I/O multiplexing,  常用于非阻塞的socket的编程中: 简单介绍一下这个模块,更多内容查看 pyt ...

  4. css3-盒模型display:-webkit-box;的使用

    提到移动布局不得不提到盒模型display:-webkit-box;这个属性,在移动布局中浮动已经不在重要,相反自适应成为主要的需求,所以display:-webkit-box;变得尤为重要. box ...

  5. 原生tab切换(适用于购物商城中订单管理模块,例如:待付款/待发货/待收货等订单状态)

    <!-- 头部tab栏切换 html部分--> <ul class="title-bar"> <li @click="changeStatu ...

  6. Harbor使用 -- 修改80端口

    在公网上,一般情况下都不暴露默认端口,避免被攻击! 以下修改harbor的默认80端口为其他端口! 我这里示例修改为1180端口! 注意:以下步骤都是在harbor目录下操作!!! 1.修改docke ...

  7. STL 小白学习(1) 初步认识

    #include <iostream> using namespace std; #include <vector> //动态数组 #include <algorithm ...

  8. numpy delete

    手动安装 sudo rm -rf /usr/local/lib/python2.7/site-packages/numpy/ sudo rm -rf /usr/local/lib/python2.7/ ...

  9. 十年京东Java程序员的工作总结,写给迷茫中的你!

    很多年前,刚刚从大学毕业的时候,很多公司来校招.其中最烂俗的一个面试问题是:“你希望你之后三到五年的发展是什么?”.我当时的标准回答是(原话):“成为在某一方面能够独当一面的技术专家“.后来经历了几家 ...

  10. leetcode python 010

    #实现正则表达式匹配并支持'.'和'*'.#''匹配任何单个字符.#'*'匹配前面元素的零个或多个.#匹配应覆盖整个输入字符串(非部分).##Some examples:##isMatch(" ...