No duplicate variable
Terry Reedy
tjreedy at udel.edu
Fri Nov 20 15:31:17 EST 2009
King wrote:
> class A(object):
> def __init__(self, value=0.):
> self.value = value
>
> class B(A):
> def __init__(self, value=None):
> A.__init__(self)
> self.value = value
>
> obj = B()
>
> When "B" initializes, it overwrite "value" variable of "A". How do I
> make sure that no variable should not be defined with names of "A" in
> "B"?
By knowing the public interface of A before you inherit from it, so you
do not do that.
More information about the Python-list
mailing list