Christopher Barker writes: > The funny thing is, in this thread, while I dont really see the need for > adding += to StringIO to make a string builder, I kind of like the idea of > adding += to the File protocol -- for all file-like objects. I like the > compactness of: > > with open(filename, 'w') as outfile: > a_loop_of_somesort: > outfile += something > > And hey, then you'd get your string builder!
Yah, but you also get outfile.seek(some_random_place) outfile += something for free. This seems like what mathematicians call "abuse of notation." While normally the rule is "consenting adults", I can see folks with severe space constraints "reusing the buffer" with something like outfile.seek(0) a_loop_of_somesort: outfile += something size = outfile.tell() outfile.seek(0) built_string = outfile.read(size) I'm not a fan. Steve _______________________________________________ Python-ideas mailing list -- python-ideas@python.org To unsubscribe send an email to python-ideas-le...@python.org https://mail.python.org/mailman3/lists/python-ideas.python.org/ Message archived at https://mail.python.org/archives/list/python-ideas@python.org/message/TYPGJG5CMAXG2K2ESBAHCOTREHCTRO6R/ Code of Conduct: http://python.org/psf/codeofconduct/