PEP 214 - Why not print >> string?
Aaron Swartz
me at aaronsw.com
Thu Jan 10 22:01:03 EST 2002
On 2002-10-01 1:22 PM, in article
5Ul%7.12734$wd4.1464622 at atlpnn01.usenetserver.com, "Steve Holden"
<sholden at holdenweb.com> wrote:
>>> Unfortunately, this would seem to require that a variable name be bound
> to a
>>> string value in order to indicate that the result of the print statement
>>> should overwrite it. Then the prints are rebinding the named variable
>>> (obviously, since the string values are immutable). This seems a little
>>> bizarre.
>>
>> I'm not sure I see why. It would function similarly to += on strings.
>> print >> string, 'value'
>> would be equivalent to:
>> string += 'value'
>> (except you'd get the nice print formatting rules).
>>
>
> Well, doesn't string += "value" rebind the name string?
Yes. The "I'm not sure I see why" was in response to "This seems a little
bizarre", not to "the prints are rebinding the named variable". Sorry if I
was confusing. To restate:
I'm not sure I see why this is so bizarre. += rebinds the variable, and it
was accepted into the language.
--
[ "Aaron Swartz" ; <mailto:me at aaronsw.com> ; <http://www.aaronsw.com/> ]
More information about the Python-list
mailing list