[Tutor] Class inheiritance question
D-Man
dsh8290@rit.edu
Sun, 31 Dec 2000 12:52:05 -0500
Yes! That's where the power of iheritance and polymorphism lie.
On Fri, Dec 29, 2000 at 05:17:35PM -0600, Brad Chandler wrote:
> I have created a sub class called Positionrlgn of a base class called
> Position. I've redefinded one of the functions successfully, but now I need
> to redefine a variable. How do I redefine a value which is set in the
> __init__ function.
>
> For example, my base class starts like this:
>
> class Position:
> def __init__(self, dbrow):
> self.currentsalary=dbrow[0]
>
> my sub class starts like this:
>
> class Positionrlgn(projectclass.Position):
def __init__( sef , dbrow ) :
# first call the parent's ctor
# this will set currentsalary and everything else as
# before
Position.__init__( self , dbrow )
# now change current salary to whatever the new value
# should be
self.currentsalary = 2000000
>
> Can I modify the __init__ function so that only the one value is altered and
> the rest are left intact?
-D