Handling errors in open
Jacek Generowicz
jmg at ecs.soton.ac.uk
Mon Apr 17 13:55:23 EDT 2000
Jacek Generowicz wrote before checking his spelling:
> 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:
IOError does the trick !
>
> print "You lied about that file."
>
> Jacek
More information about the Python-list
mailing list