From e869a09bc2e0fbd988fdc19014b8b0ad7e4b97c9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20D=C3=B8rum?= <dorum@noisolation.com> Date: Mon, 19 Jun 2023 16:55:16 +0200 Subject: add str.splitlines method The new splitlines method on str is intended to replace usage of fs.read('whatever').strip().split('\n'). The problem with the .strip().split() approach is that it doesn't have a way to represent empty lists (an empty string becomes a list with one empty string, not an empty list), and it doesn't handle Windows-style line endings. --- docs/markdown/snippets/add_str_splitlines_method.md | 3 +++ 1 file changed, 3 insertions(+) create mode 100644 docs/markdown/snippets/add_str_splitlines_method.md (limited to 'docs/markdown/snippets') diff --git a/docs/markdown/snippets/add_str_splitlines_method.md b/docs/markdown/snippets/add_str_splitlines_method.md new file mode 100644 index 0000000..6787f17 --- /dev/null +++ b/docs/markdown/snippets/add_str_splitlines_method.md @@ -0,0 +1,3 @@ +## Added str.splitlines method + +[[str.splitlines]] can now be used to split a string into an array of lines. -- cgit v1.1