javapythonexceptioncustom-exceptions

What is the Python equivalent of Java's UnsupportedOperationException?


I'm looking at Python's built-in exceptions and wondering what the closest equivalent of Java's UnsupportedOperationException is. NotImplementedError is close but seems to suggest something slightly different. Should I be using RuntimeError or implementing my own Exception?


Solution

  • The closest equivalent is to simply not implement the unsupported method. The resulting exception if you try to use the nonexistent method is an AttributeError.