Oct-03-2018, 03:30 PM
i have searched the internet and found 50 code examples for errno here:
(1) Python errno.ENOENT() Examples,
(2) Using Python errno,
(3) Working with Exception in Python
but with more or less identical syntax:
I need to run this code successfully:
(1) Python errno.ENOENT() Examples,
(2) Using Python errno,
(3) Working with Exception in Python
but with more or less identical syntax:
try: ... ... ... ... except OSError as e: if e.errno != errno.ENOENT:Is there no other way than using
try:
?I need to run this code successfully:
#! /usr/bin/python import os import errno fileInfo = 0 ''' There is supposed to be a file, outPrime.txt. If the file is not in the directory, the system generates an errno and reports FileNotFoundError. How to bypass this report and continue, to create a file outPrime.txt if there isn't any, but exit if there is one? I am trying to achieving something like the FAUX codes below:''' fileInfo = os.stat('outPrime.txt') catch = os.errno.errorcode(os.stat('outPrime.txt')) print(catch) '''