Re: About instance.name look up order

2011-12-29 Thread Ian Kelly
On Thu, Dec 29, 2011 at 9:07 AM, Prim wrote: > class C: >    def x(self): >        print 'x method' >    def __getattr__(self, attr): >        print 'in __getattr__ method' >        return attr > c = C() > c.x --> print in __getattr__ method, then throw TypeError: 'str' > object is not callable >

Re: About instance.name look up order

2011-12-29 Thread Kev Dwyer
Prim wrote: > First, sorry about my poor english. > Put these in IPython under ubuntu. > - > class C: > def __init__(self): > self.x = 1 > def print(self): > print self.x > c = C() > c.x --

About instance.name look up order

2011-12-29 Thread Prim
First, sorry about my poor english. Put these in IPython under ubuntu. - class C: def __init__(self): self.x = 1 def print(self): print self.x c = C() c.x --> 1, so c.x mean a attr of c named