Python Error Class Hierarchy
Contents |
This module never needs to be imported explicitly: the exceptions are provided in the built-in namespace python filenotfounderror as well as the exceptions module. For class exceptions, python custom exception in a try statement with an except clause that mentions a particular class, that
Python Valueerror Example
clause also handles any exception classes derived from that class (but not exception classes from which it is derived). Two exception classes that are not
Python Exception Message
related via subclassing are never equivalent, even if they have the same name. The built-in exceptions listed below can be generated by the interpreter or built-in functions. Except where mentioned, they have an "associated value" indicating the detailed cause of the error. This may be a string or a tuple python exception class methods containing several items of information (e.g., an error code and a string explaining the code). The associated value is the second argument to the raise statement. If the exception class is derived from the standard root class BaseException, the associated value is present as the exception instance's args attribute. User code can raise built-in exceptions. This can be used to test an exception handler or to report an error condition "just like" the situation in which the interpreter raises the same exception; but beware that there is nothing to prevent user code from raising an inappropriate error. The built-in exception classes can be subclassed to define new exceptions; programmers are encouraged to derive new exceptions from the Exception class or one of its subclasses, and not from BaseException. More information on defining exceptions is available in the Python Tutorial under User-defined Exceptions. The following exception
here for a quick overview of the site Help Center Detailed answers to any questions
Python Errno
you might have Meta Discuss the workings and policies of this python attributeerror object has no attribute site About Us Learn more about Stack Overflow the company Business Learn more about hiring developers python 3 exceptions or posting ads with us Stack Overflow Questions Jobs Documentation Tags Users Badges Ask Question x Dismiss Join the Stack Overflow Community Stack Overflow is a https://docs.python.org/2/library/exceptions.html community of 6.2 million programmers, just like you, helping each other. Join them; it only takes a minute: Sign up Print the Python Exception/Error Hierarchy up vote 6 down vote favorite 4 Is the any command line option in python to print the Exception/Error Class hierarchy? The output should be similar to http://docs.python.org/2/library/exceptions.html#exception-hierarchy http://stackoverflow.com/questions/18296653/print-the-python-exception-error-hierarchy python class exception share|improve this question edited Dec 9 '14 at 3:37 alecxe 218k33254421 asked Aug 18 '13 at 7:16 Sivasubramaniam Arunachalam 3,077104289 add a comment| 1 Answer 1 active oldest votes up vote 12 down vote accepted inspect module might help, specifically getclasstree() function: Arrange the given list of classes into a hierarchy of nested lists. Where a nested list appears, it contains classes derived from the class whose entry immediately precedes the list. inspect.getclasstree(inspect.getmro(Exception)) Or, you can recursively go through __subclasses__() down by an inheritance tree, like this: def classtree(cls, indent=0): print '.' * indent, cls.__name__ for subcls in cls.__subclasses__(): classtree(subcls, indent + 3) classtree(BaseException) prints: BaseException ... Exception ...... StandardError ......... TypeError ......... ImportError ............ ZipImportError ......... EnvironmentError ............ IOError ............... ItimerError ............ OSError ......... EOFError ......... RuntimeError ............ NotImplementedError ......... NameError ............ UnboundLocalError ......... AttributeError ......... SyntaxError ............ IndentationError ............... TabError ......... LookupError ............ IndexError ............ KeyError ............ CodecRegistryError ......... ValueError ............ UnicodeError .
Python - Basic Syntax Python - Variable Types Python - Basic Operators Python - Decision Making Python - Loops Python - Numbers Python - Strings Python - Lists Python - Tuples Python - Dictionary Python - Date & Time https://www.tutorialspoint.com/python/python_exceptions.htm Python - Functions Python - Modules Python - Files I/O Python - Exceptions Python https://grass.osgeo.org/grass70/manuals/libpython/exceptions.html Advanced Tutorial Python - Classes/Objects Python - Reg Expressions Python - CGI Programming Python - Database Access Python - Networking Python - Sending Email Python - Multithreading Python - XML Processing Python - GUI Programming Python - Further Extensions Python Useful Resources Python - Questions and Answers Python - Quick Guide Python - Tools/Utilities Python - Useful python exception Resources Python - Discussion Selected Reading Developer's Best Practices Questions and Answers Effective Resume Writing HR Interview Questions Computer Glossary Who is Who Python Exceptions Handling Advertisements Previous Page Next Page Python provides two very important features to handle any unexpected error in your Python programs and to add debugging capabilities in them − Exception Handling: This would be covered in this tutorial. Here is a list standard Exceptions available in python error class Python: Standard Exceptions. Assertions: This would be covered in Assertions in Python tutorial. List of Standard Exceptions − EXCEPTION NAME DESCRIPTION Exception Base class for all exceptions StopIteration Raised when the next() method of an iterator does not point to any object. SystemExit Raised by the sys.exit() function. StandardError Base class for all built-in exceptions except StopIteration and SystemExit. ArithmeticError Base class for all errors that occur for numeric calculation. OverflowError Raised when a calculation exceeds maximum limit for a numeric type. FloatingPointError Raised when a floating point calculation fails. ZeroDivisonError Raised when division or modulo by zero takes place for all numeric types. AssertionError Raised in case of failure of the Assert statement. AttributeError Raised in case of failure of attribute reference or assignment. EOFError Raised when there is no input from either the raw_input() or input() function and the end of file is reached. ImportError Raised when an import statement fails. KeyboardInterrupt Raised when the user interrupts program execution, usually by pressing Ctrl+c. LookupError Base class for all lookup errors. IndexErrorKeyError Raised when an index is not found in a sequence.Raised when the specified key is not found in the dictionary. NameError Raised when an identifier is not found in the local or global namespace. UnboundLocalErrorEnvironmentError Raised when trying to acce
and the built-in namespace. It is recommended that user-defined exceptions inherit from Exception. See the documentation for the exception inheritance hierarchy. exception ArithmeticError¶ Bases: exceptions.StandardError Base class for arithmetic errors. exception AssertionError¶ Bases: exceptions.StandardError Assertion failed. exception AttributeError¶ Bases: exceptions.StandardError Attribute not found. exception BaseException¶ Bases: object Common base class for all exceptions args¶ message¶ exception BufferError¶ Bases: exceptions.StandardError Buffer error. exception BytesWarning¶ Bases: exceptions.Warning Base class for warnings about bytes and buffer related problems, mostly related to conversion from str or comparing to str. exception DeprecationWarning¶ Bases: exceptions.Warning Base class for warnings about deprecated features. exception EOFError¶ Bases: exceptions.StandardError Read beyond end of file. exception EnvironmentError¶ Bases: exceptions.StandardError Base class for I/O related errors. errno¶ exception errno filename¶ exception filename strerror¶ exception strerror exception Exception¶ Bases: exceptions.BaseException Common base class for all non-exit exceptions. exception FloatingPointError¶ Bases: exceptions.ArithmeticError Floating point operation failed. exception FutureWarning¶ Bases: exceptions.Warning Base class for warnings about constructs that will change semantically in the future. exception GeneratorExit¶ Bases: exceptions.BaseException Request that a generator exit. exception IOError¶ Bases: exceptions.EnvironmentError I/O operation failed. exception ImportError¶ Bases: exceptions.StandardError Import can't find module, or can't find name in module. exception ImportWarning¶ Bases: exceptions.Warning Base class for warnings about probable mistakes in module imports exception IndentationError¶ Bases: exceptions.SyntaxError Improper indentation. exception IndexError¶ Bases: exceptions.LookupError Sequence index out of range. exception KeyError¶ Bases: exceptions.LookupError Mapping key not found. exception KeyboardInterrupt¶ Bases: exceptions.BaseException Program interrupted by user. exception LookupError¶ Bases: exceptions.StandardError Base class for lookup errors. exception MemoryError¶ Bases: exceptions.StandardError Out of memory. exception NameError¶ Bases: exceptions.StandardError Name not found globally. exception NotImplementedError¶ Bases: exceptions.RuntimeError Method or function hasn't been implemented yet. exception OSError¶ Bases: exceptions.EnvironmentError OS system call failed. exception OverflowError¶ Bases: exceptio