I am not understanding the "Self" object in the following Python code:
>>> class Ancestor( object ):
def __init__( self ):
self.name = "Ancestor"
def getName( self ):
return self.name
>>> class Base1( Ancestor ):
def __init__( self ):
self.name = "Base1"
super( Base1, self ).__init__( )
def getName( self ):
return self.name
>>> class Base2( Base1 ):
def __init__( self ):
self.name = "Base2"
super( Base2, self ).__init__( )
def getName( self ):
return self.name
def getB1Name( self ):
return super( Base2, self ).getName( )
>>> b2 = Base2( )
>>> b2.getName( )
'Ancestor'
>>> b2.getB1Name( )
'Ancestor'
I am not able to understand the result. I was expecting the result for b2.getName( ) to be "Base2" and the result for b2.getB1Name( ) to be "Base1"