print "hello", >> file

phil hunt philh at cabalamat.uklinux.net
Tue Feb 25 10:31:35 EST 2003


On Tue, 25 Feb 2003 08:57:20 GMT, Alex Martelli <aleax at aleax.it> wrote:
>Hilbert wrote:
>
>> Hello,
>> 
>> Why does the following result in an error?
>> 
>> f = file("welcome.txt","w")
>> print "hello", >> f
>
>Because the "print>>BAH" syntax is all wacko.  You
>need to code:
>    print >> f, "hello"

Wouldn't it be nice if appending to a file, appending to a string 
and appending to stdout had the same syntax?

E.g.:

   f = file("somefilename", "w")
   f << "hello"

   s = "some string"
   s << "hello"

   out << "hello"



-- 
|*|*|  Philip Hunt <philh at cabalamat.org>  |*|*|
|*|*|  "Memes are a hoax; pass it on"     |*|*|





More information about the Python-list mailing list