Python 2.4 inline if statements
I am creating an existing django project on dreamhost webserver as long as I have everything to work properly. However I developed under python 2.5 and dreamhost uses python 2.4 by default. The next line seems to be a syntax error due to the if keyword:
'parent': c.parent.pk if c.parent is not None else None
^
This is the case where this form of statement if
was introduced in Python 2.5, if it is so easy to change what would make it compatible with Python 2.4?
Or should I just upgrade to Python 2.5. I have already installed python 2.5 in a directory under my home directory and have successfully executed the python interpreter in version 2.5. If I want to use Python 2.5 for everything, where can I install this?
a source to share
Yes, this inline if type has been added since 2.5 , released almost 4 years ago. You can upgrade Dreamhost version like this
a source to share
http://www.diveintopython.net/power_of_introspection/and_or.html
(1 and [a] or [b])[0]
'parent': (c.parent is not None and [c.parent.pk] else [None])[0]
a source to share