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"?
Prashant
To avoid these kinds of clashes, you can use the double-undescore
syntax. It will create a mangled name that looks like
_module_class_variablename
By this, the two different variable get distinct names.
*However*, this is neither a proper way of making variables private, nor
are name-clashes something that should arise more than every now-and-then.
Instead, try rather renaming value to something more meaningful.
Diez
By knowing the public interface of A before you inherit from it, so you
do not do that.