Re: Pythonic way for handling file errors

2007-10-10 Thread danielx
On Oct 10, 12:28 pm, Paul Hankin <[EMAIL PROTECTED]> wrote: > On Oct 10, 7:41 pm, wink <[EMAIL PROTECTED]> wrote: > > > I would like to know what would be considered the most > > Pythonic way of handling errors when dealing with files, > > solutions that seem reasonable using 2.5: > > The best way

Re: Pythonic way for handling file errors

2007-10-10 Thread Paul Hankin
On Oct 10, 7:41 pm, wink <[EMAIL PROTECTED]> wrote: > I would like to know what would be considered the most > Pythonic way of handling errors when dealing with files, > solutions that seem reasonable using 2.5: The best way to handle errors is to catch the exceptions that are raised by the code t

Pythonic way for handling file errors

2007-10-10 Thread wink
Hello, I would like to know what would be considered the most Pythonic way of handling errors when dealing with files, solutions that seem reasonable using 2.5: --- try: f = open('afile', 'r') content = f.read() error = 200 except Exception: error = 404 finally: if locals().has