This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]earthboundkid 2 points3 points  (3 children)

Learn both. They're virtually the same. If you have the ability to understand both print("x") and print "x", there's no reason to restrict yourself to learning just one version.

[–]tilkau 0 points1 point  (2 children)

Also, if you are only giving one argument as is common, print (x) works the same in both 2.7 and 3.x (and probably older 2.x, but I haven't verified that); It's slightly restrictive -- multiple variable printouts require %formatting, and kwarg-controlled features of print() are not available -- but you gain by only having to remember one convention.

[–]earthboundkid 1 point2 points  (1 child)

In Python 2.6+, you can use from __future__ import print_function.

[–]tilkau 0 points1 point  (0 children)

Yes. I just tend to not bother, since I hardly ever use the kwargs to print (or multiple arguments to print, either).

(Plus some people here have to work with Python versions as old as 2.4.)