i

Python Programming

File/Directory Methods

There are three ways for this :

•    File-Object-Methods: This provides provides functions to manipulate files.

•    OS-Object Methods: This helps to process files as well as directories.

Python has also exception handling method for handle any unexpected error.

List of Standard Exceptions −

Exception Name / Description

1    Exception>>>Base class for the all exceptions

2    StopIteration>>> Raised when next() method of iterator does not point to any of the object.

3    SystemExit>>>>Raised by sys.exit() function.

4    StandardError>>>Base class for all built in exceptions except StopIteration / SystemExit.

5    ArithmeticError>>>>Base class for all errors for the numeric-calculation.

6    OverflowError>>>>It raises when calculation exceeds the maximum limit for numeric -type.

7    FloatingPointError>>>It raises when floating-point calculation - fails.

8    ZeroDivisionError>>>It raises when division or modulo by zero takes place for numeric - types.

9    AssertionError>>>It raises in case of failure of Assert-statement.

10    AttributeError>>>It raises in case of failure of attribute reference / assignment.

11    EOFError>>>It raises when no input either raw_input() / input() function and end of file reached.

12    ImportError>>>>Raised if  import statement fails.

13    KeyboardInterrupt>>>> Raised when user interrupts program execution by pressing Ctr+c.

14    LookupError>>>Base class all lookup errors.

15    IndexError>>> Raised when an index not found in sequence.

16    KeyError>>>Raised when specified key is not found/dictionary.

17    NameError>>>It raises when an identifier is not found in local / global namespace.

18    UnboundLocalError>>> Raised when trying to access local variable in function or method but no value assigned to it.

19    EnvironmentError>>>Base class for all exceptions outside Python-environment.

20    IOError>>>It raises when an input/ output operation fails.

21    IOError>>> Raised for operating-system-related errors.

22    SyntaxError>>> Raised when there is error in the python syntax.

23    IndentationError>>>Raised when indentation is not mentioned properly.

24    SystemError>>> Raised when interpreter finds an internal problem but when this error is encountered the python interpreter don’t exist.

25    SystemExit>>>It raises when Python interpreter is quit by using sys.exit() function.

26    TypeError>>>Raised when an operation / function is attempted that is invalid for data type.

27    ValueError>>>Raised when built-in function for data type has valid type of argument but the arguments have invalid values specified.

28    RuntimeError>>>Raised when generated error don’t fall into any category.

29    NotImplementedError>>>Raised when abstract method that needs to be implemented in the inherited class is not implemented.