[Python-Dev] Replacement for print in Python 3.0

Steve Holden steve at holdenweb.com
Fri Sep 2 06:30:42 CEST 2005

Steven Bethard wrote:
> [Guido van Rossum]
>>And good riddance! The print statement harks back to ABC and even
>>(unvisual) Basic. Out with it!
> [Barry Warsaw]
>>I have to strongly disagree.  The print statement is simple, easy to
>>understand, and easy to use.
> [Paul Moore]
>>I agree with Barry. In particular, the behaviour of adding spaces
>>between items is something I find very useful, and it's missing from
>>the functional forms.
... as proposed, but ...
> While I agree that mostly the print statement is "simple, easy to
> understand, and easy to use", I've seen the trailing-comma version
> cause confusion for a lot of newbies.  I wouldn't mind at all if the
> trailing-comma version disappeared in Python 3.0 -- if you need this
> kind of complicated output, you can always use sys.stdout.write and/or
> string formatting.
... the trailing-comma version is indeed BASIC voodoo of ancient 
heritage, and not something I'd personally miss.

> The spaces-between-items point that Paul Moore makes is IMHO the best
> argument against the proposed write*() functions.  I think we *do*
> need a statement or function of some sort that does the most basic
> task: writing a line to sys.stdout that calls str() on each of the
> elements and joins them with spaces.  That is, I think we need to keep
> *something* with functionality like:
>     def XXX(*args):
>         sys.stdout.write('%s\n' % ' '.join(str(a) for a in args))
> Note that this would keep the Hello World example simple:
>     XXX(greeting, name)

Of course, for Python 3.0 if we lose the keyword there's nothing to stop 
us calling the convenience function "print". With the removal of the 
trailing-comma functionality we'd only have to add parentheses to 2.X 
print statements to have them work :-)

Next question: could the function have a sensible return value, or is 
None the best possible result?

hesitating-to-suggest-minus-one-ly y'rs  - steve
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