1

I have a foo.py Python file containing print "bar" code. When I want to python foo.py my code, here is the error : SyntaxError: Missing parentheses in call to 'print'. Do you know how to avoid this error without adding '(' and ')' to my print function ?

Thanks !

1
  • 1
    For python 3 print is a function and must have ()
    – mmmmmm
    Commented Jan 25, 2019 at 16:37

1 Answer 1

0

If your script is compatible then you can force use of Python2 by running it something like

python2 foo.py

or

python2.7 foo.py

That is, of course, to purely answer your question as to "using the command line to bypass" the issue.

A rewrite of the code for either 2-and-3 compatibility, using 2to3 for conversion, or refactoring for Python3 would be the other non-command-line approach.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .