Hello,

I am using things like:

except Exception as inst:

and

with open("myfile.txt") as f:
    for line in f:
        print line

Things that seems to be new in python 2.6 and higher, however reading
http://docs.python.org/tutorial/errors.html and this not clear when this new
syntaxes appeared.

My trouble is that I want to make something similar above compatible with
python 2.5, but when running python2.5 I got:

except Exception as msg:
                      ^
SyntaxError: invalid syntax

If there's a way (e.g. from __future__ ..., inherited modified Exception
class, etc) that could give a solution to keep my code in python 2.6 syntax
as above but compatible with python 2.5, that would be appreciated.

Many thanks in advance,

Alan
-- 
Alan Wilter S. da Silva, D.Sc. - CCPN Research Associate
Department of Biochemistry, University of Cambridge.
80 Tennis Court Road, Cambridge CB2 1GA, UK.
>>http://www.bio.cam.ac.uk/~awd28<<
-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to