[Tutor] print in py3

Chris “Kwpolska” Warrick kwpolska at gmail.com
Sun Dec 22 12:43:21 CET 2013


On Sun, Dec 22, 2013 at 11:14 AM, Steven D'Aprano <steve at pearwood.info> wrote:
> That's the answer to your question: in Python 2, print is a statement,
> not a function. That has many consequences, but the relevant one is that
> statements don't require brackets (parentheses for Americans reading)
> around the arguments.

If Python 3 compatibility is needed/desired, one can do

from __future__ import print_function

in order to make Python 2 operate like Python 3.

> (It is commas, not parentheses, which create tuples.)

…unless you want an empty tuple, in which case it’s just () — without
any commas whatsoever.

-- 
Chris “Kwpolska” Warrick <http://kwpolska.tk>
PGP: 5EAAEA16
stop html mail | always bottom-post | only UTF-8 makes sense


More information about the Tutor mailing list