Problem with python
Grant Edwards
grant.b.edwards at gmail.com
Sat Sep 4 22:11:50 EDT 2021
On 2021-09-04, Peter J. Holzer <hjp-python at hjp.at> wrote:
> On 2021-09-04 14:29:47 -0500, Igor Korot wrote:
>> Will this syntax work in python 2?
>
> Yes. It's just a redundant pair of parentheses.
Not really. With the parens, it doesn't produce the same results in
2.x unless you import the print function from the future:
Python 3.9.6 (default, Aug 9 2021, 12:35:39)
[GCC 10.3.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> print(1,2)
1 2
Python 2.7.18 (default, Jul 18 2021, 14:51:54)
[GCC 10.3.0] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> print(1,2)
(1, 2)
Python 2.7.18 (default, Jul 18 2021, 14:51:54)
[GCC 10.3.0] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> from __future__ import print_function
>>> print(1,2)
1 2
More information about the Python-list
mailing list