0

How to make all my print statements in python program to print() ?

I made my python program in PYTHON2.7 and for 3 version print() is used instead of print statement,how to replace them all provided the arguments of print statement are not altered. Approx 221 replacements are to be done,so please provide me with a suitable suggestion. If question sounds relevant,please give an upvote.

26th May 2018, 6:46 PM
Krish Gupta
Krish Gupta - avatar
8 odpowiedzi
+ 5
Check this out ;) https://code.sololearn.com/ce918WeOlUa7/?ref=app Although that's probably the easiest part of the porting, as Jan Markus indicated... Plus it has to be enhanced with other cases like when you have spaces inside the print statement. Possibly the best to do it with regex...
26th May 2018, 9:09 PM
Kuba Siekierzyński
Kuba Siekierzyński - avatar
+ 3
I was to slow with my Script. But I am also sure that is a Problem you should solve coding 😉 https://code.sololearn.com/cyvVuyXVzhqU/?ref=app
26th May 2018, 9:23 PM
Sebastian Keßler
Sebastian Keßler - avatar
+ 1
one possibility would have been using "from future import print_function" or something like that at the top of your programs but that only works if you do it beforehand
26th May 2018, 7:36 PM
Amaras A
Amaras A - avatar
0
You can find all print and replace with print() in an IDE
26th May 2018, 7:04 PM
Paul Grasser
Paul Grasser - avatar
0
Jan Markus there are 775 lines in my program
26th May 2018, 8:56 PM
Krish Gupta
Krish Gupta - avatar
0
Paul Grasser but what about arguments??
26th May 2018, 8:57 PM
Krish Gupta
Krish Gupta - avatar
0
Look in the official documentation: https://docs.python.org/3/howto/pyporting.html
26th May 2018, 8:57 PM
Manuel Maier
Manuel Maier - avatar
0
but Kuba Siekierzyński correcting at 222 places is very hectic
26th May 2018, 9:18 PM
Krish Gupta
Krish Gupta - avatar