Handling errors in open

Jacek Generowicz jmg at ecs.soton.ac.uk
Mon Apr 17 19:42:34 CEST 2000


Hi,

Is there a way to prevent a Python script from
terminating when `open' fails, and have it handle
the error more helpfully . . . I was thinking
along these lines:


from sys import argv

try:
    file = open(argv[1],"r")
except IOerror:
    print "You lied about that file."


Jacek





More information about the Python-list mailing list