>>>>> "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))) vs 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 hack. 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 of. 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 costs. -Barry
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4