What exception shall I raise when os.path.exists fails?

P

Peng Yu

I want to raise an exception when os.path.exists fails. I looked
through the exception list on the menu. I'm not sure if IOError is the
most appropriate exception I should use. Could somebody let me know?
Thank you!

import os.path

def direct_target(path):
while os.path.islink(path):
path = os.path.join(os.path.dirname(path), os.readlink(path))

if not os.path.exists(path):
raise IOError
else:
return path
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
474,184
Messages
2,570,978
Members
47,561
Latest member
gjsign

Latest Threads

Top