[issue13857] Add textwrap.indent() as counterpart to textwrap.dedent()

2012-06-12 Thread Chris Jerdonek
Chris Jerdonek added the comment: Great. Looks good! -- ___ Python tracker ___ ___ Python-bugs-list mailing list Unsubscribe: http:/

[issue13857] Add textwrap.indent() as counterpart to textwrap.dedent()

2012-06-11 Thread Nick Coghlan
Changes by Nick Coghlan : -- resolution: -> fixed stage: patch review -> committed/rejected status: open -> closed ___ Python tracker ___ ___

[issue13857] Add textwrap.indent() as counterpart to textwrap.dedent()

2012-06-11 Thread Nick Coghlan
Nick Coghlan added the comment: Ezra (and anyone interested) may want to take a look at the checked in version to see some of the changes I made while preparing the patch for commit. - name changes and slight restructure as discussed on the review - splitlines() invocation changed as discussed

[issue13857] Add textwrap.indent() as counterpart to textwrap.dedent()

2012-06-11 Thread Roundup Robot
Roundup Robot added the comment: New changeset 6f7afe25d681 by Nick Coghlan in branch 'default': Close #13857: Added textwrap.indent() function (initial patch by Ezra http://hg.python.org/cpython/rev/6f7afe25d681 -- nosy: +python-dev resolution: -> fixed stage: patch review -> committe

[issue13857] Add textwrap.indent() as counterpart to textwrap.dedent()

2012-06-11 Thread Nick Coghlan
Changes by Nick Coghlan : -- assignee: -> ncoghlan stage: needs patch -> patch review ___ Python tracker ___ ___ Python-bugs-list mai

[issue13857] Add textwrap.indent() as counterpart to textwrap.dedent()

2012-05-29 Thread Nick Coghlan
Nick Coghlan added the comment: I created #14957 to cover improving the str.splitlines docs. For this patch, I think Chris is right that it should be using str.splitlines(True) and joining on "''" instead of "'\n'" so that Windows line endings get preserved. -- _

[issue13857] Add textwrap.indent() as counterpart to textwrap.dedent()

2012-05-29 Thread R. David Murray
R. David Murray added the comment: That's why it's a different function :) (Well, that and universal newline support). But I can see that explaining the difference between split and splitlines would be worthwhile. -- ___ Python tracker

[issue13857] Add textwrap.indent() as counterpart to textwrap.dedent()

2012-05-29 Thread Chris Jerdonek
Chris Jerdonek added the comment: Perhaps because that's what str.split() does: >>> "a\nb".split("\n") ['a', 'b'] >>> "a\nb\n".split("\n") ['a', 'b', ''] >>> "a\nb\n\n".split("\n") ['a', 'b', '', ''] -- ___ Python tracker

[issue13857] Add textwrap.indent() as counterpart to textwrap.dedent()

2012-05-29 Thread R. David Murray
R. David Murray added the comment: Why would you expect it to? >>> 'a\nb'.splitlines() ['a', 'b'] >>> 'a\nb\n'.splitlines() ['a', 'b'] >>> 'a\nb\n\n'.splitlines() ['a', 'b', ''] That's exactly what I would intuitively expect, and I don't see how it could possibly do anything else. --

[issue13857] Add textwrap.indent() as counterpart to textwrap.dedent()

2012-05-29 Thread Nick Coghlan
Nick Coghlan added the comment: Added some review comments. I'm thinking the docs for str.splitlines() could really do with an update to say explicitly that a trailing newline *doesn't* append an empty string to the result. -- ___ Python tracker <

[issue13857] Add textwrap.indent() as counterpart to textwrap.dedent()

2012-05-12 Thread Chris Jerdonek
Chris Jerdonek added the comment: Should the function work for strings with non-Unix line endings? http://docs.python.org/dev/py3k/reference/lexical_analysis.html#physical-lines For example, should indent("abc\r\n", "") return the same string, and should "\r\n" get indented by default? -

[issue13857] Add textwrap.indent() as counterpart to textwrap.dedent()

2012-05-12 Thread Chris Jerdonek
Chris Jerdonek added the comment: I'd like to see this enhancement as well. It seems that not even a TextWrapper is capable of a simple indent (because TextWrapper methods operate on "paragraphs" rather than lines). -- nosy: +cjerdonek ___ Python

[issue13857] Add textwrap.indent() as counterpart to textwrap.dedent()

2012-04-22 Thread Michael . Elsdörfer
Changes by Michael.Elsdörfer : -- nosy: +elsdoerfer ___ Python tracker ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail

[issue13857] Add textwrap.indent() as counterpart to textwrap.dedent()

2012-02-19 Thread Vladimir Rutsky
Changes by Vladimir Rutsky : -- nosy: +rutsky ___ Python tracker ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.pytho

[issue13857] Add textwrap.indent() as counterpart to textwrap.dedent()

2012-02-02 Thread Ezra Berch
Ezra Berch added the comment: Sorry, I guess I wasn't clear. The trailing-newlines issue was an issue with the conditional expression ncoghlan suggested. It's fixed in the patch I submitted (and covered by the tests). -- ___ Python tracker

[issue13857] Add textwrap.indent() as counterpart to textwrap.dedent()

2012-02-02 Thread Georg Brandl
Georg Brandl added the comment: IMO removing trailing newlines is not acceptable. You could use splitlines(keepends=True) to keep final newlines (but then the default function that determines lines to indent needs to ignore these newlines). -- ___

[issue13857] Add textwrap.indent() as counterpart to textwrap.dedent()

2012-01-30 Thread Ezra Berch
Ezra Berch added the comment: I've created a patch using the conditional expression in msg151945. The one problem I found with it is that when the input string is terminated by a newline it removes that newline. I've added an optional third argument: a function which determines which lines a

[issue13857] Add textwrap.indent() as counterpart to textwrap.dedent()

2012-01-30 Thread Nick Coghlan
Nick Coghlan added the comment: Please go ahead! And Georg is right - the short spelling doesn't handle the first line correctly. It also suffers from the "trailing whitespace" problem that Amaury pointed out in my original version. The tests for the new function should check both those case

[issue13857] Add textwrap.indent() as counterpart to textwrap.dedent()

2012-01-30 Thread Justin Wehnes
Justin Wehnes added the comment: Just wondering if someone is already working on this or am I free to supply a patch? -- nosy: +jwehnes ___ Python tracker ___ _

[issue13857] Add textwrap.indent() as counterpart to textwrap.dedent()

2012-01-29 Thread Georg Brandl
Georg Brandl added the comment: Otherwise +1. -- ___ Python tracker ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.p

[issue13857] Add textwrap.indent() as counterpart to textwrap.dedent()

2012-01-29 Thread Georg Brandl
Georg Brandl added the comment: BTW, the short spelling looks like it wouldn't indent the first line. -- nosy: +georg.brandl ___ Python tracker ___ _

[issue13857] Add textwrap.indent() as counterpart to textwrap.dedent()

2012-01-25 Thread Jon Brandvein
Jon Brandvein added the comment: > If such a function is added, I'd like the option to not indent empty lines: > trailing spaces are often not a good idea. >From dedent's documentation, it wasn't immediately clear to me that it ignores >blank lines when determining common whitespace. (In fact

[issue13857] Add textwrap.indent() as counterpart to textwrap.dedent()

2012-01-25 Thread Nick Coghlan
Nick Coghlan added the comment: I'd actually suggest that as the default behaviour (and is a good argument in favour of a dedicated function in textwrap - both suggested alternatives will blithely add whitespace to otherwise empty lines). To handle the empty line requires either switching to

[issue13857] Add textwrap.indent() as counterpart to textwrap.dedent()

2012-01-25 Thread Amaury Forgeot d'Arc
Amaury Forgeot d'Arc added the comment: If such a function is added, I'd like the option to not indent empty lines: trailing spaces are often not a good idea. -- nosy: +amaury.forgeotdarc ___ Python tracker _

[issue13857] Add textwrap.indent() as counterpart to textwrap.dedent()

2012-01-25 Thread Nick Coghlan
Nick Coghlan added the comment: David Miller pointed out a shorter spelling: s.replace('\n', '\n' + (4 * ' ')) Still not particularly obvious to the reader (or writer), though. -- ___ Python tracker

[issue13857] Add textwrap.indent() as counterpart to textwrap.dedent()

2012-01-24 Thread Nick Coghlan
New submission from Nick Coghlan : As far I am aware, the simplest way to indent a multi-line string is with the following snippet: '\n'.join((4 * ' ') + x for x in s.splitlines()) It would be a lot simpler and clearer if I could just write that as "textwrap.indent(s, 4 * ' ')". (i.e. in