[Python-Dev] New Wiki page - PrintAsFunction

Nick Coghlan ncoghlan at gmail.com
Sat Sep 3 14:26:25 CEST 2005


Terry Reedy wrote:
> "Ron Adam" <rrr at ronadam.com> wrote in message 
> news:43195EB1.3090406 at ronadam.com...
> 
>># standard printing
>>write.ln(1, 2, 3)
> 
> 
>># print without trailing newline
>>write(1, 2, 3)
> 
> 
> This violates this design principle:
> When there are two options and one is overwhelmingly more common in use (in 
> this case, with newline added, at least 95%) the common case should be 
> easier, not harder.

Having write/writeln as builtins has that problem too (with writeln being more
common, but having the less obvious and longer name), but that pair of
functions is still what is currently recorded in PEP 3000 as the candidate
replacement for the print statement.

Unfortunately, giving "write" the behaviour of "writeln" would result in a
confusing difference between "sys.stdout.write('Hello world!')" and
"write('Hello world!')", where the latter appends a trailing newline, but the
former doesn't.

I figure the naming of any replacement function for the print statement is
going to end up squarely in Guido's court, particularly given that the need
for a workable transition strategy makes it difficult to use the most obvious
name (i.e., print).

Cheers,
Nick.

-- 
Nick Coghlan   |   ncoghlan at gmail.com   |   Brisbane, Australia
---------------------------------------------------------------
             http://boredomandlaziness.blogspot.com



More information about the Python-Dev mailing list