Interface & Implementation

Gabriel Genellina gagsl-py2 at yahoo.com.ar
Tue Dec 16 10:44:02 CET 2008


En Fri, 12 Dec 2008 19:48:09 -0200, Lie Ryan <lie.1296 at gmail.com> escribió:

> but if you really want it, simple inheritance might be better anyway,
> though not really pythonic:
>
> class MyIfc(object):
>     def myMeth1(self): return NotImplemented
>     def myMeth2(self): return NotImplemented
> class MyClass(MyIfc):
>     def myMeth1(self):
>         # some implementation
>     def myMeth2(self):
>         # some implementation
>
> # some might notice the (ab)use of NotImplemented sentinel there

I'd raise NotImplementedError instead.

-- 
Gabriel Genellina




More information about the Python-list mailing list