Oct-18-2016, 07:08 AM
Oct-18-2016, 10:14 AM
It is 2 to 3, you attempt to modify 3 to what? 

Oct-18-2016, 10:38 AM
(Oct-18-2016, 10:14 AM)wavic Wrote: [ -> ]It is 2 to 3, you attempt to modify 3 to what?
well, he "attempts" to convert simple python 2 script that has single print statement that prints empty tuple...
I didn't try this myself, but I assume Skaperen did it right that's the result he gets. Anyway - from the docs:
Quote:Since some print statements can be parsed as function calls or statements, 2to3 cannot always read files containing the print function.
Oct-18-2016, 10:46 AM
(Oct-18-2016, 10:38 AM)buran Wrote: [ -> ]well, he "attempts" to convert simple python 2 script that has single print statement that prints empty tuple...Hm! It looks like python3 print function to me? May be it's what you say.
Oct-18-2016, 10:51 AM
Exactly. That single line is legitimate in both python 2 (as a print statement) and in python 3 (as a print function). And the docs make it clear in this case 2to3 is not to be blamed
Oct-18-2016, 03:04 PM
That's already a valid python3 file. So there isn't any conversion that needs to take place.
Oct-19-2016, 04:25 AM
(Oct-18-2016, 03:04 PM)nilamo Wrote: [ -> ]That's already a valid python3 file. So there isn't any conversion that needs to take place.
in python 2 it is a print statement that prints an empty tuple







Oct-19-2016, 04:48 AM
In 2to3 doc.
You can of course also put this line in python 2.x code.
Quote:When the -p is passed, 2to3 treats print as a function instead of a statement.
You can of course also put this line in python 2.x code.
from __future__ import print_function print()
Oct-19-2016, 06:51 AM
true, but that's not the challenge. the challenge is to get code that does the same thing now in python3 and keep it simple. how simple can it be done in python3? is this the best case?
print('()')?
Oct-19-2016, 07:28 AM
(Oct-19-2016, 06:51 AM)Skaperen Wrote: [ -> ]true, but that's not the challenge. the challenge is to get code that does the same thing now in python3 and keep it simple. how simple can it be done in python3? is this the best case?
print('()')?
well, I start to be confused about all this. If you want the python 3 code to print empty tuple, then it is as follows
print(())
Output:Python 3.5.2 (default, Jul 17 2016, 00:00:00)
[GCC 4.8.4] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> print (())
()
>>>
I don't understand why the complications with printing the str '()'. If you want to print empty tuple, do it...The original questions was regarding unexpected behaviour using 2to3 tool