On Sat, Feb 27, 2010 at 5:41 PM, tarek...@gmail.com <tarek...@gmail.com> wrote: > Hi, > > I am currently using oauth2.py library, and it works fine on one of my > PC's (python2.5), but later on when I tried to use it with python2.4 > the following line (line 332 in > http://github.com/simplegeo/python-oauth2/blob/master/oauth2/__init__.py) > showed a syntax error > > items = [(k, v if type(v) != ListType else sorted(v)) for k,v in > sorted(self.items()) if k != 'oauth_signature'] > > So it there a way to convert this line to a python2.4 compliant > syntax.
This part is your problem: (k, v if type(v) != ListType else sorted(v)) Conditional expressions like that were added in v2.5: http://docs.python.org/whatsnew/2.5.html#pep-308-conditional-expressions Here's an untested substitute: def sort_or_tuple(k, v): if type(v) != ListType: return k, v else: return sorted(v) items = [sort_or_tuple(k,v) for k,v in sorted(self.items()) if k != 'oauth_signature'] Of course, the more obvious solution is just to upgrade your Python; it's well worth it! Cheers, Chris -- http://blog.rebertia.com -- http://mail.python.org/mailman/listinfo/python-list