For youtr try, except, finally:

you can construct something like this:
try:
    try:
        print 'egg' + 1
    except ValueError, e:
        print e
finally:
    print 'spam'

It results in:
py>
spam

Traceback (most recent call last):
  File "C:/Martin/test.py", line 3, in -toplevel-
    print 'egg' + 1
TypeError: cannot concatenate 'str' and 'int' objects
py>

If you catch the TypeError you get:


try:
    try:
        print 'egg' + 1
    except TypeError, e:
        print e
finally:
    print 'spam'

py> 
cannot concatenate 'str' and 'int' objects
spam
py>

-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to