A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://mail.python.org/pipermail/python-dev/2003-April/034359.html below:

[Python-Dev] [PEP] += on return of function call result

[Python-Dev] [PEP] += on return of function call result [Python-Dev] [PEP] += on return of function call resultWalter Dörwald walter@livinglogic.de
Thu, 03 Apr 2003 10:53:17 +0200
Greg Ewing wrote:

> Andrew Koenig <ark@research.att.com>:
> 
> 
>>So the behavior of
>>
>>        foo = d.setdefault(r,'')
>>        foo += "test %d\n" % t
>>
>>depends on what type foo has, and the OP didn't say.
> 
> I assumed that the code snippet was from his actual application, in
> which case he *did* want it to work on strings, in which case, even if
> he had the feature he wanted, it wouldn't have helped him.
> [...]
> Being forced to find another way to update the value in this case is a
> feature, because the absence of such a way when the value is immutable
> makes it clear that there's no way to do what you're trying to do!

Mutable (or at least appendable) strings should probably be done with
StringIO/cStringIO. How about adding support for __iadd__ and
__str__ (and __unicode__) to both?

Bye,
    Walter Dörwald





RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4