Using command line to bypass "Missing parentheses in call to 'print'"

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 !

Kevin VALERIO

Posted 2019-01-24T16:08:28.920

Reputation: 11

1For python 3 print is a function and must have () – user151019 – 2019-01-25T16:37:27.530

Answers

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.

Marakai

Posted 2019-01-24T16:08:28.920

Reputation: 111