Thinking about "print >>"

Roy Smith roy at popmail.med.nyu.edu
Fri Sep 1 18:46:04 EDT 2000


I havn't followed the entire discussion of "print >>", so forgive me if 
this covers ground that's been gone over already.

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.  Then instead of doing "print >> 
sys.stdout foo, bar", you could do "sys.stdout.print (foo, bar)".  You 
would then define the print statement to be a synonym for 
"sys.stdout.print (stuff after the 'print' keyword)"

What do you get out of this?

You keep the special case of a print statement, with all the simplicity 
for teaching people python as a first language, etc.

You get the ability to do "print" to any file you want.

You don't have to add any syntax, or any reserved words, to the existing 
language.

You get that warm and fuzzy OO feeling every time you use it :-)

Am I missing something?  It seems like it answers all the needs that 
I've seen expressed in the various arguments.



More information about the Python-list mailing list