[Python-ideas] Explicitly defining a string buffer object (aka StringIO += operator)

2020-03-29 Thread Paul Sokolovsky
Hello, 1. Intro It is a well-known anti-pattern to use a string as a string buffer, to construct a long (perhaps very long) string piece-wise. A running example is: buf = "" for i in range(5): buf += "foo" print(buf) An alternative is to use a buffer-like object explicitly desi

[Python-ideas] Re: Explicitly defining a string buffer object (aka StringIO += operator)

2020-03-29 Thread Andrew Barnert via Python-ideas
> On Mar 29, 2020, at 10:57, Paul Sokolovsky wrote: > > > It is a well-known anti-pattern to use a string as a string buffer, to > construct a long (perhaps very long) string piece-wise. A running > example is: > > buf = "" > for i in range(5): > buf += "foo" > print(buf) > > An alternat