46 - Built in Exception in Python

46 - Built in Exception in Python


46 - Built in Exception in Python

#python #python3 #pythonexception #exception

@kingoftechniques6864

All instances in Python must be instances of a class that derives from BaseException. Two exception classes that are not related via subclassing are never equivalent, even if they have the same name. The built-in exceptions can be generated by the interpreter or built-in functions.

There are several built-in exceptions in Python that are raised when errors occur. These built-in exceptions can be viewed using the local() built-in functions as follows :

An exception is an event, which occurs during the execution of a program that disrupts the normal flow of the program’s instructions. In general, when a Python script encounters a situation that it cannot cope with, it raises an exception. An exception is a Python object that represents an error.

When a Python script raises an exception, it must either handle the exception immediately otherwise it terminates and quits.

If you have some suspicious code that may raise an exception, you can defend your program by placing the suspicious code in a try: block. After the try: block, include an except: statement, followed by a block of code which handles the problem as elegantly as possible.

A single try statement can have multiple except statements. This is useful when the try block contains statements that may throw different types of exceptions.

You can also provide a generic except clause, which handles any exception.

After the except clause(s), you can include an else-clause. The code in the else-block executes if the code in the try: block does not raise an exception.

The else-block is a good place for code that does not need the try: block’s protection.


Content

14.88 -> foreign
30.96 -> this class is the best class for those
33.6 -> building exceptions that are for
35.44 -> awarenesses arithmetic errors such as
37.84 -> double class today
39.52 -> arithmetic error
42 -> arithmetic exceptionally
62.53 -> [Music]
74.98 -> [Music]
85.52 -> print this statement is rising in
87.92 -> arithmetic exception
96 -> this statement is rise in arithmetic
98.32 -> exception
104.06 -> [Music]
109.41 -> [Music]
126.96 -> the base class for those exceptions that
129.2 -> arise when a key or index used
132.4 -> on a mapping or sequence in valid or not
135.52 -> found the exception rise or key error
138.4 -> index error look up
141.54 -> [Music]
183.21 -> [Music]
191.03 -> [Music]
222.51 -> [Music]
237.98 -> [Music]
322.88 -> s
328.19 -> [Music]
363.08 -> [Music]
377.22 -> [Music]
387.69 -> [Music]
392.479 -> x minus
421.28 -> lower in attributes error here is rised
423.599 -> when an attribute reference are
425.68 -> assignment fields such as when
428.24 -> non-existent attribute is referenced at
430.96 -> best error however
433.84 -> you attribute
448.72 -> foreign
467.45 -> [Music]
519.12 -> heads and end of file condition uf
521.76 -> without reading any data the fields
524.64 -> method like red line returned in empty
527.279 -> strings
548.65 -> [Music]
568.72 -> foreign
573.81 -> [Music]
582.5 -> [Music]
607.02 -> [Music]
617.12 -> for pythag

Source: https://www.youtube.com/watch?v=aypaFiFqtVI