class A(object):
    def a(self, b=1):
        print 'Up'
    d = {1 : a}
    def b( self ):
        print self.d[1]
        print self.b
        print self.d[1].__get__( self, A )()
        # print self.d[1]()
class B( object ):
    def a( self ):
        print 'here??'
        return 10000
    d = {1 : a}
    def b( self ):
        print 'hurray'
o = A()
o.b()
b = B()
type( o ).__dict__['b'].__get__( b, type( b ) )()
Hi Folks,
I was going through Python: Bind an Unbound Method? and http://users.rcn.com/python/download/Descriptor.htm and trying to experiment on my learning.
But, I have hit some new doubts now:-
- In the last line of my code, I'm able to use __get__withbobject and instance:type(b). This only works if methodbis defined inclass B. Why is it so?
- Even though the last line requires me to provide a method binclass B, still the methodbinclass Agets called. Why is it so?
- To my utter surprise, after the above step, I notice that the method aofclass Ais not called by the code of methodbofclass A; instead, it calls the methodaofclass B. Why is it so?
I'm quite confused after seeing this behaviour. I might also need to learn more on descriptors. But, it would be a great help if you could answer my doubts
 
     
    