views:

156

answers:

1

I'm trying to install Chris Atlee's python Poster library so I can upload a file using a HTTP POST query from within my script.

On python 2.3, when I type # python setup.py install, I get the following error. The install continues, but I can't >>> import poster later on.

byte-compiling build/bdist.linux-x86_64/egg/poster/encode.py to encode.pyc
  File "build/bdist.linux-x86_64/egg/poster/encode.py", line 112
    @classmethod
    ^
SyntaxError: invalid syntax
byte-compiling build/bdist.linux-x86_64/egg/poster/streaminghttp.py to streaminghttp.pyc
  File "build/bdist.linux-x86_64/egg/poster/streaminghttp.py", line 114
    newheaders = dict((k,v) for k,v in req.headers.items()
                              ^
SyntaxError: invalid syntax
byte-compiling build/bdist.linux-x86_64/egg/poster/__init__.py to __init__.pyc

Any pointers?

A: 

Python 2.3 didn't have support for decorators (that's what @classmethod is) or list comprehensions (which is the second error), so you're either going to have to find an older version of Poster, or stick with urllib/urllib2 for doing your HTTP work.

Actually, it looks like Poster was created around July, 2008, so there's unlikely to be a version that supports Python 2.3 even if you could find the original source. Any particular reason you can't upgrade to the latest Python 2.x at least?

Nick Bastin