login
Holden Web
What you'll need to know tomorrow

Comments on A Python 3 Idiom?

Python 3 just cleans off those little last ugly bi...

Anonymous · 2010-02-18T08:55:24.094000

Python 3 just cleans off those little last ugly bits of Python. Lovely.

well, in python 2.5, the following works... print...

tshirtman · 2010-02-18T09:06:03.180000

well, in python 2.5, the following works...

print powers(10)

not much of a difference... ;)

forget it, I read to fast, your point is valid. so...

tshirtman · 2010-02-18T09:09:50.581000

forget it, I read to fast, your point is valid. sorry.

Nice find!

ShadyTyrant · 2010-02-18T10:56:41.133000

Nice find!

print(powers(10)) works fine in python 2.5, 2.6. ...

নাসিম · 2010-02-18T12:33:10.046000

print(powers(10))

works fine in python 2.5, 2.6. Why it shouldn't be used that way?

@নাসিম: That will produce output, but the output i...

Steve · 2010-02-18T13:05:01.310000

@নাসিম: That will produce output, but the output it produces will be the strr() of the resulting tuple, including the parentheses and commas.

In Python 3 the elegant syntax for tuple expansion passes each value as an individual argument to print(), and each value returned appears as a number.

Even if you have redefined the print() function (as one can validly do in Python 3) the updated function will operate correctly.

You can use this import in 2.6 to run the code. f...

Wayne Witzel III · 2010-02-18T21:58:51.276000

You can use this import in 2.6 to run the code.

from __future__ import print_function

Page 1 of 1

Back to post