diff options
author | Ezio Melotti <ezio.melotti@gmail.com> | 2011-09-28 14:37:55 (GMT) |
---|---|---|
committer | Ezio Melotti <ezio.melotti@gmail.com> | 2011-09-28 14:37:55 (GMT) |
commit | d8b509b192a67f0f217ae52ed81fc91bc27a1818 (patch) | |
tree | adab8922723e179e67d546100d19d06d444d7599 /Lib/difflib.py | |
parent | a6e50f589fa328a77b70cde0747f70210c650f49 (diff) | |
download | cpython-d8b509b192a67f0f217ae52ed81fc91bc27a1818.zip cpython-d8b509b192a67f0f217ae52ed81fc91bc27a1818.tar.gz cpython-d8b509b192a67f0f217ae52ed81fc91bc27a1818.tar.bz2 |
#13012: use splitlines(keepends=True/False) instead of splitlines(0/1).
Diffstat (limited to 'Lib/difflib.py')
-rw-r--r-- | Lib/difflib.py | 20 |
1 files changed, 10 insertions, 10 deletions
diff --git a/Lib/difflib.py b/Lib/difflib.py index e6cc6ee..d34bbca 100644 --- a/Lib/difflib.py +++ b/Lib/difflib.py @@ -800,7 +800,7 @@ class Differ: ... 2. Explicit is better than implicit. ... 3. Simple is better than complex. ... 4. Complex is better than complicated. - ... '''.splitlines(1) + ... '''.splitlines(keepends=True) >>> len(text1) 4 >>> text1[0][-1] @@ -809,7 +809,7 @@ class Differ: ... 3. Simple is better than complex. ... 4. Complicated is better than complex. ... 5. Flat is better than nested. - ... '''.splitlines(1) + ... '''.splitlines(keepends=True) Next we instantiate a Differ object: @@ -896,8 +896,8 @@ class Differ: Example: - >>> print(''.join(Differ().compare('one\ntwo\nthree\n'.splitlines(1), - ... 'ore\ntree\nemu\n'.splitlines(1))), + >>> print(''.join(Differ().compare('one\ntwo\nthree\n'.splitlines(True), + ... 'ore\ntree\nemu\n'.splitlines(True))), ... end="") - one ? ^ @@ -1269,8 +1269,8 @@ def context_diff(a, b, fromfile='', tofile='', Example: - >>> print(''.join(context_diff('one\ntwo\nthree\nfour\n'.splitlines(1), - ... 'zero\none\ntree\nfour\n'.splitlines(1), 'Original', 'Current')), + >>> print(''.join(context_diff('one\ntwo\nthree\nfour\n'.splitlines(True), + ... 'zero\none\ntree\nfour\n'.splitlines(True), 'Original', 'Current')), ... end="") *** Original --- Current @@ -1339,8 +1339,8 @@ def ndiff(a, b, linejunk=None, charjunk=IS_CHARACTER_JUNK): Example: - >>> diff = ndiff('one\ntwo\nthree\n'.splitlines(1), - ... 'ore\ntree\nemu\n'.splitlines(1)) + >>> diff = ndiff('one\ntwo\nthree\n'.splitlines(keepends=True), + ... 'ore\ntree\nemu\n'.splitlines(keepends=True)) >>> print(''.join(diff), end="") - one ? ^ @@ -2034,8 +2034,8 @@ def restore(delta, which): Examples: - >>> diff = ndiff('one\ntwo\nthree\n'.splitlines(1), - ... 'ore\ntree\nemu\n'.splitlines(1)) + >>> diff = ndiff('one\ntwo\nthree\n'.splitlines(keepends=True), + ... 'ore\ntree\nemu\n'.splitlines(keepends=True)) >>> diff = list(diff) >>> print(''.join(restore(diff, 1)), end="") one |