[Python-Dev] Replacement for print in Python 3.0

Barry Warsaw barry at python.org
Tue Sep 6 04:24:09 CEST 2005


On Mon, 2005-09-05 at 20:52, Guido van Rossum wrote:

> We could decide not to provide (b) directly, since it is easily
> reduced to (c) using an appropriate format string ("%s" times the
> number of arguments). But I expect that use case (b) is pretty
> important, and not everyone likes having to use format strings. This
> could be reduced to a special case of the Swiss Army Knife (...Not)
> rule.

I'm not sure.  I do agree with your design principles (though I might
call it "Sometime's a Spoon's Just a Spoon" ;) but thinking about my own
uses of print, I think we could easily get away with just (a) and (c). 
I think someone else felt the same way in an earlier response to my
strawman, pointing out that the inline Separator instances wasn't really
any more usable than just degenerating to the format string version. 
There's no doubt that the format string approach gives you direct
control over every character.

Eliminating the newline argument from print() would reduce the number of
reserved keyword arguments in my strawman by half.  Maybe we could even
rename 'to' to '__to__' (!) to eliminate the other namespace wart.  Is
this really too horrible:

print('$user forgot to frobnicate the $file!\n',
      user=username, file=file.name, __to__=sys.stderr)

> BTW we could use "from __future__ import printing" to disable the
> recognition of 'print' as a keyword in a particular module -- this
> would provide adequate future-proofing.

+1
-Barry

-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 307 bytes
Desc: This is a digitally signed message part
Url : http://mail.python.org/pipermail/python-dev/attachments/20050905/f95cc558/attachment.pgp


More information about the Python-Dev mailing list