mark jason wrote:
On Dec 10, 11:55 am, Steven D'Aprano wrote:
# By the way, IOError is not the only exception you could see.
thanks for the help Steven. Is it OK to catch Exception instead of
IOError ?
In some operation which can cause many errors ,can I use the
following?
try:
mark jason wrote:
> hi
> I was trying out some file operations and was trying to open a non
> existing file as below
>
> def do_work(filename):
> try:
> f = open(filename,"r");
> print 'opened'
> except IOError, e:
> print 'failed',e.message
> finally:
>
On Dec 10, 11:55 am, Steven D'Aprano wrote:
> # By the way, IOError is not the only exception you could see.
thanks for the help Steven. Is it OK to catch Exception instead of
IOError ?
In some operation which can cause many errors ,can I use the
following?
try:
do_something()
except Ex
On Thu, 09 Dec 2010 22:16:17 -0800, mark jason wrote:
> hi
> I was trying out some file operations and was trying to open a non
> existing file as below
>
> def do_work(filename):
> try:
> f = open(filename,"r");
> print 'opened'
> except IOError, e:
> print 'faile
hi
I was trying out some file operations and was trying to open a non
existing file as below
def do_work(filename):
try:
f = open(filename,"r");
print 'opened'
except IOError, e:
print 'failed',e.message
finally:
f.close()
print 'closed'
if __na