How to inspect who is caller of func and who is the class of instance
1. Who is the class of self instance ?
class aa(object):
def a(self): if self.__class__.__name__ == 'aa':
print "aa, a func()"
elif self.__class__.__name__ == "bb":
print "bb, a func()" class bb(aa):
def b(self):
print "aa, b func()" aa().a()
bb().a() ---------------------------------------------------------------------
result :
aa, a func()
bb, a func()
2.Who is the caller of function
import inspect class aa(object):
def a(self):
frame = inspect.currentframe() print "The caller is %s" %frame.f_back.f_code.co_name def callerOfa(self):
self.a() aa().callerOfa()
aa().a() ---------------------------------------------------------------
result:
The caller is callerOfa
The caller is <module>
How to inspect who is caller of func and who is the class of instance的更多相关文章
- jquery颜色选择器
本站下载 第二种:纯JAVASCRIPT: <html> <head> <meta http-equiv="Content-Type" content ...
- event.srcElement ,event.fromElement,event.toElement
自然,我们都习惯了 IE,在 IE 中要在函数中获得各事件对象很容易,直接用 event.event.srcElemtn.event.fromElement.event.toElement 就行了.在 ...
- Javascript 俄罗斯方块 游戏代码解释!
俄罗斯方块代码说明 /** 名称:Javascript 俄罗斯方块! 作者:Gloot 邮箱:glootz@gmail.com QQ:345268267 网站:http://www.cnblogs.c ...
- js限制文本框只可以输入数字
封装了一下,要用的话直接调用下面getEvent函数即可 function getEvent() { if (document.all) { return window.event; //for ...
- JavaScript滚动条插件源码
这是过年的时候自己写的js滚动条插件的源码,做出的效果自己并不满意,正因为做的并不满意所以回头重新巩固和深入学习js,这个插件有如下几个不太满意的地方: 内容的过度效果,可以参阅QQ客户端最近会话列表 ...
- .net异步编程
现在电脑大部分都是多核心,在处理多线程方便有很大优势,异步调用方法的时候可以立即返回执行其他程序,进行异步编程会让程序运行效率更高. 我也是刚刚关注异步编程方面知识,也有很多不是很理解,所以想向大神请 ...
- WebFrom 的js日期控件
1.WdatePicker.js /* * My97 DatePicker 4.7 Release * License: http://www.my97.net/dp/license.asp */ v ...
- Html模板
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 5.0 Transitional//EN"> <!-- saved from ur ...
- IE firefox 兼容性整理
1.尽量用jquery操作. 2.jquery取值时要用准确的方法,attr(), val(), text(), html(). 例如: <span value="a"> ...
随机推荐
- 7.openstack之mitaka搭建dashboard
部署控制面板dashboard 控制节点 1.安装软件包 yum install openstack-dashboard -y 2.配置 vim /etc/openstack-dashboard/lo ...
- PHP 函数(数组字符串)
函数四要素: 参数 变量 返回值 函数体 函数分类: 1.有参数的函数: function Show() { echo "hello"; } Show(); 2. 有返回 ...
- js脚本语言
alert(): 输出 字符串 转成整数 parseint(字符串):运算符与表达式% 取余 aler(10%2)余0 逻辑运算符&&并 ||或 !非 判断条件比较运算符== 等于 ! ...
- 解决SVN Upgrade working copy问题
解决SVN Upgrade working copy,无法上传到svn上的解决方案是SVN Upgrade working copy老有问题,而且还特别慢.还有种方法,将原来上传到svn的项目中有个. ...
- wex5平台放入tabs组件后运行时显示空白
用tabs组件设置为充满布局时--给window组件增加一个class:x-full-screen
- [Leetcode] Roman to Integer
Given a roman numeral, convert it to an integer. Input is guaranteed to be within the range from 1 t ...
- 转:AngularJS的Filter用法详解
Filter简介 Filter是用来格式化数据用的. Filter的基本原型( '|' 类似于Linux中的管道模式): {{ expression | filter }} Filter可以被链式使用 ...
- 转OSGchina中,array老大的名词解释
转OSGchina中,array老大的名词解释 转自:http://ydwcowboy.blog.163.com/blog/static/25849015200983518395/ osg:: Cle ...
- 使用express-generator初始化你的项目目录
express 4.x以后将express命令独立到 express-generator包中,所以想使用express初始化项目目录,可以npm install express-genrator ...
- Mybatis拦截器 mysql load data local 内存流处理
Mybatis 拦截器不做解释了,用过的基本都知道,这里用load data local主要是应对大批量数据的处理,提高性能,也支持事务回滚,且不影响其他的DML操作,当然这个操作不要涉及到当前所lo ...