pre-PEP: Print Without Intervening Space

Antoon Pardon apardon at forel.vub.ac.be
Tue Mar 15 05:42:02 EST 2005


Op 2005-03-11, Marcin Ciura schreef <marcin.NOSPAMciura at NOSPAMpolsl.pl>:
>      Moreover, all of them require creating one or two temporary
>      objects to hold the entire result.  If the programmers use one of
>      them without qualms, it is only because their mind is warped by
>      the limitation of print.
>
>      Using write() is not especially appealing either, especially if
>      the print statements are used elsewhere in the code:

Personnaly I think just the reversed. I don't use print anywhere
unless for debugging purposes. I always use write 

>          import sys
>          for x in seq:
>              sys.stdout.write(fn(x))
>          print # or sys.stdout.write('\n')
>
>      The proposed extension to the print statement is to use two
>      commas to signal that no space should be written after an
>      expression:
>
>          for x in seq:
>              print fn(x),,
>          print
>
>      To quote "The Zen of Python" [2]: "Beautiful is better than ugly.
>      Simple is better than complex.  Readability counts."

IMO that favors using always write instead of using print with it
various extentions.

For instance if I do the following

       a = 1,

I have assigned a one element tuple to a.

But if I do

       print 1,

It doesn't print a one element tuple.

-- 
Antoon Pardon



More information about the Python-list mailing list