print "hello", >> file
Jp Calderone
exarkun at intarweb.us
Tue Feb 25 13:47:04 EST 2003
On Tue, Feb 25, 2003 at 06:36:20PM +0000, phil hunt wrote:
> 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'
>
This rebinds "s" to a new string object. I suppose this hypothetical "<<"
operator could do the same. OTOH, why does anyone want yet -another- way to
concatenate strings?
Jp
--
There are 10 kinds of people: those who understand binary and those who do
not.
--
up 16 days, 22:29, 4 users, load average: 0.07, 0.05, 0.01
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 196 bytes
Desc: not available
URL: <http://mail.python.org/pipermail/python-list/attachments/20030225/8c7d1854/attachment.sig>
More information about the Python-list
mailing list