Christian Heimes wrote:
Jean-Michel Pichavant wrote:
talking about approaches:

1/
class Interface:
    def foo(self):
       if self.__class__.foo == Interface.foo:
          raise NotImplementedError

2/
class Interface:
    def foo(self):
       self._foo()

    def _foo(sef):
       raise NotImplementedError

Please don't call it an interface when it's really an abstract base class. And abstract base classes are probably the solution the OP is looking for, http://docs.python.org/library/abc.html

Christian

Sadly I'm working with python 2.4. Anyway it's good to hear they've added ABC support to python, didn't know that. I didn't know there was a difference between interface and abstract classes as well. With a little bit of googling, I found out that actually Interface classes do not provide any implementation.
What I'm looking for is definitely an abstract class.

JM
--
http://mail.python.org/mailman/listinfo/python-list

Reply via email to