try except inside a with open
ganesh1pal at gmail.com
Sat Jul 21 05:43:26 EDT 2018
> (1) Since this function always returns True (if it returns at all), what
> is the point? There's no point checking the return result, since it's
> always true, so why bother returning anything?
If I don't return anything from a function it returns None. But would it
be better if for the function i.e modify_various_line(f) to atleast catch
or handle exceptions and log it for debugging purpose
""" Try modifiying various line """
f.seek(5) # Go to the 6th byte in the file
f.seek(-3, 2) # Go to the 3rd byte before the end
except IOError as e:
logging.error("Error: got %s" , % (str(e)))
More information about the Python-list