MRO inconsistency: why?

2008-10-08 Thread Ravi
Why the following code gives inconsistent method resolution order error: class X(object): x = 4 def f(self): print 'f in X' print dir(X) X.g(self) def g(self): print 'g in X' class Y(object, X): def

Re: MRO inconsistency: why?

2008-10-08 Thread Christian Heimes
Ravi wrote: Why the following code gives inconsistent method resolution order error: [...] Your problem can be reduced to: class A(object): ... pass ... A.__mro__ (class '__main__.A', type 'object') class B(object, A): ... pass ... Traceback (most recent call last): File stdin,

Re: MRO inconsistency: why?

2008-10-08 Thread Terry Reedy
Ravi wrote: Why the following code gives inconsistent method resolution order error: class X(object): x = 4 def f(self): print 'f in X' print dir(X) X.g(self) def g(self): print 'g in X' class Y(object, X): def g(self): print 'g in Y' o = Y() o.f() Calculating a linear MRO from a

Re: MRO inconsistency: why?

2008-10-08 Thread Michele Simionato
On Oct 8, 9:09 pm, Ravi [EMAIL PROTECTED] wrote: Why the following code gives inconsistent method resolution order error: snip If you want to know all the nitty-gritty details about the MRO (including the reason for the error you get) you should read this: