print "hello", >> file

phil hunt philh at cabalamat.uklinux.net
Tue Feb 25 13:36:20 EST 2003


On Tue, 25 Feb 2003 12:04:14 -0500, Peter Hansen <peter at engcorp.com> wrote:
>phil hunt wrote:
>> 
>> Wouldn't it be nice if appending to a file, appending to a string
>> and appending to stdout had the same syntax?
>> 
>>    f = file("somefilename", "w")
>>    f << "hello"
>> 
>>    s = "some string"
>>    s << "hello"
>> 
>>    out << "hello"
>
>Since you can't append to a string,

But I can:

   philh:~> python
   Python 2.0 (#1, Jan 19 2001, 17:54:27)
   [GCC 2.95.2 19991024 (release)] on linux2
   Type "copyright", "credits" or "license" for more information.
   >>>
   >>>
   >>> s = "some string"
   >>> s += "hello"
   >>> s
   'some stringhello'
          


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





More information about the Python-list mailing list