problem in with keyword

Chris Rebert clp2 at rebertia.com
Fri May 1 13:12:37 CEST 2009


On Fri, May 1, 2009 at 3:56 AM, Murali kumar <murali.au at gmail.com> wrote:
> hi all..
>
> my application runs fine in windows xp using python 2.6 and wxpython 2.8.9
>
> but in ubuntu 8.10 following error appears..  using python 2.5.2 and
> wxpython 2.8.9
>
> /home/murali/Desktop/mathdemo-configfinal/manageprofile.py:63: Warning:
> 'with' will become a reserved keyword in Python 2.6
> Traceback (most recent call last):
>   File "test.py", line 8, in <module>
>     import manageprofile as managepf
>   File "/home/murali/Desktop/mathdemo-configfinal/manageprofile.py", line 63
>     with open(self.profile, 'wb') as configfile:
>             ^
> SyntaxError: invalid syntax

According to PEP 343 (http://www.python.org/dev/peps/pep-0343/), the
`with` keyword was only added in Python 2.6

To use it in Python 2.5, you'd need to add:

from __future__ import with_statement

to any files using the `with` syntax. Or you could just upgrade to Python 2.6

Cheers,
Chris
-- 
http://blog.rebertia.com



More information about the Python-list mailing list