We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent ee49533 commit 8d701ecCopy full SHA for 8d701ec
python_arsenal/io/file.py
@@ -11,6 +11,7 @@
11
_ENCODING_UTF8 = 'utf-8'
12
13
_LINE_BREAKS = '\n\v\x0b\f\x0c\x1c\x1d\x1e\x85\u2028\u2029'
14
+_LINE_BREAK_TUPLE = tuple(_LINE_BREAKS)
15
16
17
def read_lines(filename, encoding=_ENCODING_UTF8, strip=False, skip_empty=False):
@@ -348,7 +349,7 @@ def write_lines(self, lines):
348
349
self._to_write()
350
new_lines = []
351
for line in lines:
- if not line.endswith('\n'):
352
+ if not line.endswith(_LINE_BREAK_TUPLE):
353
line += '\n'
354
new_lines.append(line)
355
self._file.writelines(new_lines)
0 commit comments