首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 开发语言 > perl python >

关于python class: callerRef的有关问题

2012-04-27 
关于python class: callerRef的问题Python codeclass A:def __init__(self):self.B_Handle B_Handleself

关于python class: callerRef的问题

Python code
class A:    def __init__(self):        self.B_Handle = B_Handle        self.VA = "A_init"        print "Class A init"    def __getattr__(self, name):        print "A.__getattr__"        print "name=%s" % name    def callref(self, callref="A",):        print "A.callref = %s" % callref        return self.B_Handle.callref(self, callref)class B:    def __init__(self):        self.VB = "B_init"        print self.VB    def callref(self, [color=#FF0000]callerRef,[/color] callref):        print "B.callref = %s" % callrefB_Handle = B()if __name__ == "__main__":    print "eval callerRef start"    a = A()    a.callref()

运行结果:
>>> B_init
eval callerRef start
Class A init
A.callref = A
B.callref = A

看到一段这样的代码, 对其中的callerRef不是很理解,请高手指点!

[解决办法]
callerRef没用上,看不出所以然,可以print一下试试...

热点排行