Method default arguments can be overridden apparently:
>>> class B:
... def meth(self, r=True): print r
>>> class D(B):
... def meth(self, r=False): print r
... D().meth()
False
>>> B().meth()
True
How is this possible ? Is it considered bad style ?
You can change signatures of overridden methods in an arbitrary way. Python doesn't care:
but if you ask
the answer is Yes, because it violates the important Liskov substitution principle:
In other words, a derived class must fulfill all contracts provided by the base class. Particularly, overridden methods must have same signatures and similar semantics. Since Python doesn't help you on that, you have to control that manually, with the help of your IDE (here Intellij IDEA):
To answer your specific question about overriding default params, I guess the answer is "it depends". If the param is an option that only used internally and doesn't affect the observable behavior of the object, there's nothing wrong about changing it:
on the other side, if the param substantially affects semantics, it's a part of the contract and shouldn't be overridden. For example, this code will be confusing