[Python-Dev] Replacement for print in Python 3.0

Guido van Rossum guido at python.org
Mon Sep 5 04:32:45 CEST 2005

On 9/4/05, Barry Warsaw <barry at python.org> wrote:
> You can definitely argue about keeping formatting and print separate,
> but I think Guido and others have explained the problems with %.

To reiterate, "%s" % x is unsafe if you aren't sure that x can't be a
tuple -- you'd have to write "%s" % (x,) if it can be one. Also,
print("%s %s" % (a, b)) looks a bit ugly with the irregular
punctuation. While I'm not going so far as to want a statement
dedicated to printing, I'm not against having some redundancy for such
an important piece of functionality.

> Also,
> we already have precedence in format+print in the logging package.  I
> actually think the logging provides a nice, fairly to use interface that
> print-ng can be modeled on.

Right. I just have one additional suggestion for the logging package
(not sure if it should apply to printf as well): if there's a problem
with the format operator, fall back to printing the format string
followed by the argument values (if any) without any formatting --
when logging, that's a much better thing to do than dying with an
exception. As I said, not sure if printf() should have the same
behavior; it's wort a try though.

--Guido van Rossum (home page: http://www.python.org/~guido/)

More information about the Python-Dev mailing list