[Python-Dev] Replacement for print in Python 3.0

Steve Holden steve at holdenweb.com
Sat Sep 3 08:58:23 CEST 2005

Nick Coghlan wrote:
> Martin Blais wrote:
> Python generally allows trailing commas so that it is easier to write sequence 
> literals which are appended to later.
> There's also the fact that a trailing comma is used to make a 1-element tuple 
> - so it could be said that the exception is actually that the comma after the 
> last item can be optionally left out when there is more than one item in the 
> sequence :)

  >>> (1,2,3,)
(1, 2, 3)
  >>> (1,2,3,,)
   File "<stdin>", line 1
SyntaxError: invalid syntax

in Python 2.4, could the double-comma be imbued with some additional 
mystical meaning that the print() function/method could recognise as 
indicating a requirement to terminate output with a space rather than a 

Python 3.0.6 (#17, Aug 13, 2008, 18:02:40)
[CC 4.6.2 (cygwin special)] on cygwin
Type "help", "copyright", "credits" or "license" for more information.
  >>> f = open("myfile.txt", "w")
  >>> f.print('foo:', foo, 'bar:', bar, 'baz:', baz,,)
  >>> if frobble > 0:
  ...     f.print('frobble', frobble)
  ... else:
  ...     f.print('no frobble today')

What other uses might this exciting new syntax (;-) find? Perhaps there 
could also be special meanings for three and four training commas, and a 
double-semicolon. Maybe it's time to consult Larry Wall?

I am aware this response seems flippant. Sorry.

I'm not against the introduction of the suggested new API, but that's 
adding to the language rather than simplifying it, so I'm not sure I 
understand the reason why the print statement must go (except to counter 
the addition of the new API), particularly since Guido's original 
venomous outburst arrived in the middle of a thread about Python 3.0 
design principles:

> [Reinhold Birkenfeld]
>>> You'd have to enclose print arguments in parentheses. Of course, the "trailing
>>> comma" form would be lost.
> And good riddance! The print statement harks back to ABC and even
> (unvisual) Basic. Out with it!

Is the principle here "Python must be different from ABC and BASIC"? In 
that case I suppose we'd better start thinking about what to use instead 
of "if" and "for". What did the print statement do to us that it must be 
cast out in this way?

I suspect the fundamental problem is that the commas do something more 
than delimit sequence members. In which case we should say so rather 
than belittling Python's ancient predecessors.

Steve Holden       +44 150 684 7255  +1 800 494 3119
Holden Web LLC             http://www.holdenweb.com/

More information about the Python-Dev mailing list