can i implement virtual functions in python ?

logistix at cathoderaymission.net logistix at cathoderaymission.net
Wed Oct 1 22:58:26 EDT 2003


"Andrew Dalke" <adalke at mindspring.com> wrote in message news:<dPGeb.11520$NX3.4712 at newsread3.news.pas.earthlink.net>...
> Me:
> > > However, I do use NotImplementedError so the exception
> > > which percolates up is more obvious than AttributeError.  It also
> > > allows me to put in a docstring describing the interface requirements
> > > of derived classes.
> 
> logistix at cathoderaymission.net:
> > Either using hasattr or or a try...except clause gets a little clunky.
> >  I'd just rather do something like:
> >
> > class abstract:
> >     def a(self): raise NotImplementedError("Virtual Method")
> >     def b(self): raise NotImplementedError("Virtual Method")
> >     def c(self): raise NotImplementedError("Virtual Method")
> 
> Well, I agreed with you ;)
> 


DOH! You did agree with me ;)  Sorry about that.  I thought you were
talking about re-raising an AttributeError as a NotImplementedError in
the except clause.




More information about the Python-list mailing list