
- Python Basic Tutorial
- Python - Home
- Python - Overview
- Python - Environment Setup
- Python - Basic Syntax
- Python - Comments
- Python - Variables
- Python - Data Types
- Python - Operators
- Python - Decision Making
- Python - Loops
- Python - Numbers
- Python - Strings
- Python - Lists
- Python - Tuples
- Python - Dictionary
- Python - Date & Time
- Python - Functions
- Python - Modules
- Python - Files I/O
- Python - Exceptions
Standard errno system symbols in Python
Every programming language has a error handling mechanism in which some errors are already coded into the compiler. In Python we have love which are associated with some standard pre-determined error codes. In this article we will see how to to get the error numbers as well as error codes which are inbuilt. And then take an example of how error code can be used.
Error codes
In this program just list out the inbuilt error numbers and error codes. Memorial we use the error no module along with the OS module.
Example
import errno import os for i in sorted(errno.errorcode): print(i,':',os.strerror(i))
Output
Running the above code gives us the following result −
1 : Operation not permitted 2 : No such file or directory 3 : No such process 4 : Interrupted function call ………… ………..
Here we demonstrate how how an area is raised and used. We consider the - No such file error as an example.
Example
try: file_name = open('Data.txt') # 2 is 'No such file or directory' except IOError as e: if e.errno == 2: print(e.strerror) print("File to be printed no found") # handle exception elif e.errno == 9: print(e.strerror) print("File will not print")
Output
Running the above code gives us the following result −
No such file or directory File to be printed no found
- Related Articles
- What is British standard system and international standard system?
- Difference between Bretton Woods System and Gold Standard
- Creating a Standard user in SAP HANA system using SQL
- How to know what the ‘errno’ means in Linux?
- Standard Data Types in Python
- Inplace vs Standard Operators in Python
- Python Standard operators as functions
- Standard way to integrate SAP with external system like .NET application
- What are Standard Data Types in Python 3?
- Python Program to Calculate Standard Deviation
- Can variables have symbols in it like the percentage symbols %?
- Determine common type following standard coercion rules in Python
- HTML Symbols
- Design File System in Python
- Add currency symbols in Excel

Advertisements