Python 2.4 inline if statements

Posted by Marcus Whybrow on Stack Overflow See other posts from Stack Overflow or by Marcus Whybrow
Published on 2010-05-02T13:52:44Z Indexed on 2010/05/02 13:57 UTC
Read the original article Hit count: 1025

I am setting up an existing django project on a dreamhost web server, so far I have got everything to work correctly. However I developed under python 2.5 and dreamhost by default uses python 2.4. The following line seems gives a syntax error because of the if keyword:

'parent': c.parent.pk if c.parent is not None else None
                       ^

Is it the case that this form of if statement was introduced in Python 2.5, if so is there an easy change that would make it compatible with Python 2.4?

Or, should I just change to Python 2.5. I have already installed python 2.5 to a directory under my home directory, and have succeeded in running the python interpreter under 2.5. If I wish to use Python 2.5 for everything, where can I set this?

© Stack Overflow or respective owner

Related posts about python

Related posts about python-2.4