overriding methods - two questions

J. Clifford Dyer jcd at sdf.lonestar.org
Mon Nov 19 15:05:43 CET 2007


On Mon, Nov 19, 2007 at 01:41:46PM +0100, Bruno Desthuilliers wrote regarding Re: overriding methods - two questions:
> 
> 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.
> 

Isn't that more what Zope-type interfaces are for than inheritance?  I'm uncertain here, but I'm not persuaded that changing signature is bad.  



More information about the Python-list mailing list