G
Greg Copeland
Okay, I have:
class Base( object ):
def __init__( self ):
self._attrib = "base"
print "Base"
def real( self ):
print "Base.real() is calling base.virtual()"
self.virtual()
def virtual( self ):
print "Base virtual()"
pass
class Mother( Base ):
def __init__( self ):
print "Mother"
super( Mother, self ).__init__()
def virtual( self ):
print self._attrib
print "virtual = Mother"
class Father( Base ):
def __init__( self ):
print "Father"
super( Father, self ).__init__()
def virtual( self ):
print self._attrib
print "virtual = Father"
class Child( Mother, Father ):
def __init( self ):
print "Child"
super( Child, self ).__init__()
self._childAttrib = "child"
def virtual( self ):
print "base attribute = " + self._attrib
print "virtual = Child"
print "childAttrib = " + self._childAttrib
rename = Child
virtual = Child
Traceback (most recent call last):
File "<stdin>", line 1, in ?
File "/usr/tmp/python-8zAJdg.py", line 51, in virtual
AttributeError: 'Child' object has no attribute '_childAttrib'
Hmmm...interesting....but okay...let's look some more...
{'_attrib': 'base'}
What??! Where the heck did self._childAttrib go? And why?
Can someone please shine some light here? Please?
Thanks in advance,
Greg
class Base( object ):
def __init__( self ):
self._attrib = "base"
print "Base"
def real( self ):
print "Base.real() is calling base.virtual()"
self.virtual()
def virtual( self ):
print "Base virtual()"
pass
class Mother( Base ):
def __init__( self ):
print "Mother"
super( Mother, self ).__init__()
def virtual( self ):
print self._attrib
print "virtual = Mother"
class Father( Base ):
def __init__( self ):
print "Father"
super( Father, self ).__init__()
def virtual( self ):
print self._attrib
print "virtual = Father"
class Child( Mother, Father ):
def __init( self ):
print "Child"
super( Child, self ).__init__()
self._childAttrib = "child"
def virtual( self ):
print "base attribute = " + self._attrib
print "virtual = Child"
print "childAttrib = " + self._childAttrib
rename = Child
base attribute = baseMother
Father
Base
virtual = Child
Traceback (most recent call last):
File "<stdin>", line 1, in ?
File "/usr/tmp/python-8zAJdg.py", line 51, in virtual
AttributeError: 'Child' object has no attribute '_childAttrib'
Hmmm...interesting....but okay...let's look some more...
{'_attrib': 'base'}
What??! Where the heck did self._childAttrib go? And why?
Can someone please shine some light here? Please?
Thanks in advance,
Greg