Thinking about "print >>"
Huaiyu Zhu
hzhu at users.sourceforge.net
Fri Sep 1 20:59:11 EDT 2000
On Fri, 01 Sep 2000 18:46:04 -0400, Roy Smith <roy at popmail.med.nyu.edu> wrote:
>It seems to me that the thing to do would be to define a "print" method
>for file objects, which is like write, but has all the pretty-print
>functionality of the print statement.
[snip]
>Am I missing something? It seems like it answers all the needs that
>I've seen expressed in the various arguments.
The current print statements take the forms
print item, item, item
print item, item, item,
Compared with sys.stdout.write, they have following advantages
- no parenthesis
- accept all kinds of items, not just strings
- multiple items separated by spaces
- default with newline
- decision on newline at the end of line
You are missing two points (no parenthesis, decision on newline at end).
The only completely satisfactory syntax would be
file.print item, item, item
file.print item, item, item,
But it seems impossible. If it is a statement, it does not start with a
keyword. If it is an expression, how do you handle the trailing comma? [1]
And do we allow other functions to go without parenthesis?
Maybe only "print >>" can keep _all_ the properties of print.
[1] If a,,b,, would be equivalent to a,None,b,None,None then there are more
possibilities. But that's another set of issues (tuple syntax, optional
arguments, ...)
Huaiyu
More information about the Python-list
mailing list