How to 'ignore' an error in Python?

Greg Ewing greg.ewing at canterbury.ac.nz
Sat Apr 29 21:04:54 EDT 2023


On 30/04/23 2:43 am, jak wrote:
> Maybe I expressed myself badly but I didn't mean to propose alternatives
> to the EAFP way but just to evaluate the possibility that it is not a
> folder.

If it's not a folder, you'll find out when the next thing you
try to do to it fails.

You could check for it earlier, but there's still the possibility
of a race condition -- someone could delete the folder and replace
it with a file in the meantime. Or just delete it and not replace
it with anything. So you need to be prepared to deal with failures
at any point.

-- 
Greg


More information about the Python-list mailing list