Hi tutors, I am studying classes a bit, and am having trouble with this
concept and would appreciate your help!
class A:
def __init__(self, name, value=1):
self.name = name
self.value = value
And now I want a subclass, one that overrides the value=1 and defaults to
value=2, how do I code that? I'm understanding subclasses that have
different methods that have different behavior, but I'm having trouble doing
this.
Do we have to call the __init__ of the parent somehow? Is it "replaced" or
overridden in an __init__ method of the subclass?
.. or stated simply:
If you have class A: which has def __init__(self, name, value=1), how do you
code a subclass B(A): that automatically starts with value=2?
_______________________________________________
Tutor maillist - [email protected]
http://mail.python.org/mailman/listinfo/tutor