'''I'm using general Exception to print out what the exception is
until I learn them, but
it will print out "[Errno 2] No such file or directory" in this case,
when the real
exception I'd need to use in an except clause is FileNotFoundError.
How do I get the
exception I need to use in the except clause from the more English-like message?
'''

#Using C:\Python33\python.exe on Win 7 in c:\python33\jimprogs
try:
    fh = open('nosuchdirectory/text/truthyfalsey.txt')
    for line in fh:
        print(line,end='')
    fh.close()
except Exception as err:
    print(err)

Jim
After indictment the bacon smuggler was put on the no-fry list
_______________________________________________
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor

Reply via email to