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