[Python-3000] print() parameters in py3k

Guido van Rossum guido at python.org
Mon Nov 20 19:11:11 CET 2006


On 11/20/06, Fredrik Lundh <fredrik at pythonware.com> wrote:
> Giovanni Bajo wrote:
>
> > Uhm, but then, why not simply:
> >
> > println(x,y,z) -> append "\n"
> > print(x,y,z) -> no terminator
> > print(x,y,z,"\r\n") -> custom terminator
>
> hey, I proposed that earlier today, but something ate my post ;-)

I don't like that as much; it doesn't have a way to change the
separator between items, so if you want your items flush together
you'll have to say

  print(x);  print(y);  println(z)

The third example above has a minor flaw in that it inserts a space
before the "\r\n".

FWIW, in case anyone proposes to "solve" this by not automatically
inserting spaces between items by default, that was quickly voted out
of the race the first time we went through this.

> while we're at it, why not add a printf as well, btw?  (defined as
> def printf(fmt, *args): print(fmt % args)).

Fine with me, although print-hating folks will probably hate it more.
BTW printf() should not automatically append a newline (can't tell
whether you intended it to do or not -- that depends on whose
definition of print() you were referring, mind or Giovanni's). Also,
it should have a file=... keyword parameter.

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


More information about the Python-3000 mailing list