PEP 214 - Why not print >> string?

Skip Montanaro skip at pobox.com
Thu Jan 10 23:46:07 CET 2002


    Robert> ISTR there also should be an attribute which the print statment
    Robert> uses to determine if it should write a space to the output
    Robert> before outputting a field. I'm too lazy to look for it in the
    Robert> docs, but it's there somewhere. 

That would be softspace...

    Robert> But it makes a lot more sense to use a function which does
    Robert> exactly the same as print and returns a string:

    Robert> def Print(*args):
    Robert>    return " ".join([str(x) for x in args])

Well, more Pythonic it may be, but the semantics of two calls to your Print
function aren't the same as executing two print statements.  The caller
would have to insert the required space or newline, depending on whether the
print statement she isn't executing has a trailing comma or not.

i-sense-another-impending-disturbance-in-the-force-ly, y'rs,

-- 
Skip Montanaro (skip at pobox.com - http://www.mojam.com/)




More information about the Python-list mailing list