overriding methods - two questions

Bruno Desthuilliers bruno.42.desthuilliers at wtf.websiteburo.oops.com
Mon Nov 19 07:41:46 EST 2007


Steven D'Aprano a écrit :
> On Fri, 16 Nov 2007 18:28:59 +0100, Bruno Desthuilliers wrote:
> 
>>> Question 1:
>>>
>>> Given that the user of the API can choose to override foo() or not, how
>>> can I control the signature that they use?
>> While technically possible (using inspect.getargspec), trying to make
>> your code idiot-proof is a lost fight and a pure waste of time.
> 
> 
> Worse: it's actually counter-productive!
> 
> The whole idea of being able to subclass a class means that the user 
> should be able to override foo() *including* the signature. 

If you see subclassing as subtyping, the signatures should always stay 
fully compatibles.




More information about the Python-list mailing list