[Tutor] intefaces in python

Alan Gauld alan.gauld at btinternet.com
Mon Jun 29 11:46:05 CEST 2009


"Amit Sethi" <amit.pureenergy at gmail.com> wrote

> Well I want to implement plug-in like mechanism for an application . I 
> want
> to define some minimum functions that any body writing a plugin has to
> implement. For that i thought an interface would be best because in a
> scenario where the function is not implemented some kind of error would
> occur. I would love to hear if you think their is a better way to achieve
> this

Well you could define a real default plugin class that actually does 
something.
Then anyone who wants to create a plugin can inherit from that and either
extend the default functions or override them with something different.

That will reduce the code that plug-in writers need to create and prevent
any error messages appearing for the user.

It also means the default plug in acts as sample code for the interface 
too.

HTH,

Alan G. 




More information about the Tutor mailing list