try/except/else/finally problem

Ben Finney bignose+hates-spam at benfinney.id.au
Thu Jun 28 19:44:21 EDT 2007


Ed Jensen <ejensen at visi.com> writes:

> I'm using:
> Python 2.3.2 (#1, Oct 17 2003, 19:06:15) [C] on sunos5
>
> And I'm trying to execute:
>
> #! /usr/bin/env python
>
> try:
>     f = file('test.txt', 'r')
> except IOError:
>     print 'except'
> else:
>     print 'else'
> finally:
>     print 'finally'
>
>
> What am I doing wrong?

You're using syntax that is valid under Python 2.5, but invalid in
earlier Python versions.

     <URL:http://www.python.org/dev/peps/pep-0341/>
     <URL:http://docs.python.org/whatsnew/pep-341.html>

-- 
 \           "Military justice is to justice what military music is to |
  `\                                          music."  -- Groucho Marx |
_o__)                                                                  |
Ben Finney



More information about the Python-list mailing list