rscare/rpass — Issue #1: Syntax error due to print statement in rpass_interface.py
Author: mistofvongola
Created: 2011-10-18 23:50:03+00:00
State: open

**Problem**: When I tried to install, I got a syntax error in rpass_interface.py:

running install
running build
running build_py
running build_scripts
running install_lib
creating /usr/local/lib/python2.7/dist-packages/rpass
copying build/lib.linux-x86_64-2.7/rpass/rpass_interface.py -> /usr/local/lib/python2.7/dist-packages/rpass
copying build/lib.linux-x86_64-2.7/rpass/rpass.py -> /usr/local/lib/python2.7/dist-packages/rpass
copying build/lib.linux-x86_64-2.7/rpass/__init__.py -> /usr/local/lib/python2.7/dist-packages/rpass
byte-compiling /usr/local/lib/python2.7/dist-packages/rpass/rpass_interface.py to rpass_interface.pyc
SyntaxError: ('invalid syntax', ('/usr/local/lib/python2.7/dist-packages/rpass/rpass_interface.py', 34, 28, " print(txtreset, end='')\n"))

byte-compiling /usr/local/lib/python2.7/dist-packages/rpass/rpass.py to rpass.pyc
byte-compiling /usr/local/lib/python2.7/dist-packages/rpass/__init__.py to __init__.pyc
running install_scripts
copying build/scripts-2.7/ru -> /usr/local/bin
copying build/scripts-2.7/rp -> /usr/local/bin
copying build/scripts-2.7/rpassword-manager -> /usr/local/bin
changing mode of /usr/local/bin/ru to 755
changing mode of /usr/local/bin/rp to 755
changing mode of /usr/local/bin/rpassword-manager to 755
running install_data
copying rpass.1 -> /usr/local/share/man/man1
creating /usr/local/share/rpass
copying rpass.example.conf -> /usr/local/share/rpass
running install_egg_info
Writing /usr/local/lib/python2.7/dist-packages/rpass-7.3.egg-info

**Possible Solutions**: The syntax error is caused by the print function. In Python 3.x, print is a function and uses the syntax you provided. In Python 2.x, print is just a statement. I was using Python 2.7.1 when I tried to install this. Assuming your code is otherwise Python 2.7.x compliant, there are two solutions that I know of:

* Change the print line to a statement:

`print txtreset,`

The comma ends the line with a space rather than a linebreak.

* Or leave the line as is and import from the future module:

`from __future__ import print_function`

This module is available in Python 2.5.x onwards.

If this code is not compatible with Python 2.x, I would specify more clearly in the documentation that it depends on Python 3.x.