[Python-Dev] extended print statement, uPre-PEP

Barry A. Warsaw bwarsaw@beopen.com
Sat, 22 Jul 2000 16:02:21 -0400 (EDT)

>>>>> "PP" == Paul Prescod <paul@prescod.net> writes:

    PP> Why not use outputfile.write directly?

Because it's less readable.

log.write('post to %s from %s, size=%d\n' % (listname, sender, len(msg)))

print 'post to', listname, 'from', sender, 'size=', len(msg)

With the former, you have to know about the rules for string
interpolation, you have to make sure you've got your tuple is the
right length, you have to remember to add the trailing newline.

    PP> print is such a hack already.

Maybe, but how often do /you/ use it?  It's an incredibly convenient

    PP> What are we trying to get at, really? What are the virtues of
    PP> print, what are the virtues of "outputfile.write" and how can
    PP> we combine them?

Some one else outlined these: print autoconverts to string, it adds
the trailing newline, it's easy for newbies to learn and it's very
readable.  I have no problem with the print statement, but it doesn't
matter because it's never going away.

I know all about the idiom for temporarily binding sys.stdout around
print statements.  /That/ is a hack because you're making a non-local
change to the system, potentially affecting code you're not even aware

So my extended print suggestion doesn't add any new keywords or
operators (forget about `@' specifically -- it's a red herring) and I
don't think it makes the statement any less readable, and in fact
improves usability for little extra cognitive or code complexity