In Python, you can't just embed arbitrary Python expressions into literal strings and have it substitute the value of the string. You need to either:
sys.stderr.write("Usage: " + sys.argv[0])
or
sys.stderr.write("Usage: %s" % sys.argv[0])
Also, you may want to consider using the following syntax of print
(for Python earlier than 3.x):
print >>sys.stderr, "Usage:", sys.argv[0]
Using print
arguably makes the code easier to read. Python automatically adds a space between arguments to the print
statement, so there will be one space after the colon in the above example.
In Python 3.x, you would use the print
function:
print("Usage:", sys.argv[0], file=sys.stderr)
Finally, in Python 2.6 and later you can use .format
:
print >>sys.stderr, "Usage: {0}".format(sys.argv[0])