Skip to main content

You are not logged in. Your edit will be placed in a queue until it is peer reviewed.

We welcome edits that make the post easier to understand and more valuable for readers. Because community members review edits, please try to make the post substantially better than how you found it, for example, by fixing grammar or adding additional resources and hyperlinks.

5
  • 1
    Good answer. I would add two things. 1) Abstract classes are emulated in Python by creating a class with methods which do nothing but raise NotImplementedError. Such classes can be instantiated but are useless in practice--they are provided as templates for subclasses. Commented Jan 21, 2012 at 4:10
  • 2
    2) Python doesn't have native language support for interfaces but are still useful enough for large projects that there are PEPs about them, and Zope created a userspace implementation (example) which is used by Twisted. Commented Jan 21, 2012 at 4:11
  • BTW, an example of an "abstract class" in the Python standard library is asynchat.async_chat. Commented Jan 21, 2012 at 4:16
  • Thanks for the suggestions about interfaces and abstract classes. I actually recall that once I created one with the NotImplementedError. Commented Jan 21, 2012 at 6:12
  • @FrancisAvila the abc module exists for handling abstract base classes a bit more elegantly, but I think most Pythonistas generally just don't bother setting them up at all - it's just that much needless busywork when you can just rely on duck typing. I know that's my feeling on the matter, anyway :) Commented Jan 21, 2012 at 10:56