On 2004 Feb 25, at 12:13, Dmitry Vasiliev wrote: > Raymond Hettinger wrote: >> Currently, writelines() does not add trailing line separators.. >> This is fine when working with readlines() but a PITA in other >> situations. >> If we added an optional separator argument, it would be easier to add >> newlines and we would gain some of the flexibility of str.join() at >> full C speed. > > Maybe not a separator but suffix, so newline will be added to last > line too? Good point. And while a separator would be a slight nuisance to express otherwise, a "suffix" isn't -- it seems to me that f.writelines(x+'\n' for x in mylines) is a rather good way of expressing "suffix each line with a \n". I don't think this suffixing operation is so widely more important than other elaborations on items of mylines to make it worth specialcasing into a writelines argument [if anything, f.writelines(str(x) for x in mylines) would be the one elaboration that seems to me to be by far the most frequent -- still not worth specialcasing though, IMHO]. Alex
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