python 3's adoption

Stephen Hansen apt.shansen at gmail.com
Wed Jan 27 08:41:32 CET 2010


On Tue, Jan 26, 2010 at 10:23 PM, Paul Rubin <no.email at nospam.invalid>wrote:

> Steven D'Aprano <steven at REMOVE.THIS.cybersource.com.au> writes:
> > print as a function is more consistent and more convenient than print as
> > a statement.
>
> Convenience is subjective, but the 3.x 'print' behavior is definitely
> inconsistent (i.e. different from 2.x).


This is a strange definition of "consistent" in my mind.

To me, consistent means that it matches the patterns and idioms of the rest
of the language at that point in time, not that it implies anything about
backwards-compatibility.

"print" as a statement was always inconsistent with the rest of the Python
language; the rules of how it behaved had to be defined in a unique way
(e.g., the behavior of trailing commas, the >> syntax to redirect what you
print to). Everything about the statement was inconsistent.

Yes, 3.0 changing the print statement to a function made it inconsistent
with previous versions, but at the same time it made it MORE consistent with
the rest of the language and Python code.

If we are defining "consistent" as "backwards-compatible", we have a
problem. Python3 is about fixing -language- inconsistencies, and allowing
for backwards incompatibility when that meant the language itself was more
consistent.



>  The change makes a lot of my
> code silently produce wrong results, too.  I often print tuples to show
> what a program is doing:
>
>    print (timestamp, 'transmogrified', blob)
>
> which in 2.x prints a parenthesized tuple that I can later read back in
> with eval.  That line of code still prints a message, but in a different
> format, instead of throwing an error.
>

That seems like bad code. If one needs to print out what a program is doing,
use the logging module.

Maybe its just me, but in my experience-- real professional code never uses
print unless it was a small script with a very narrowly focused purpose.
Changing that focus to use Python3's print function vs a statement isn't
really all that hard.

And the language is more consistent.

--S
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-list/attachments/20100126/7297475a/attachment.html>


More information about the Python-list mailing list