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

2012-06-12 Thread Chris Jerdonek
Chris Jerdonek chris.jerdo...@gmail.com added the comment: Great. Looks good! -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue13857 ___ ___

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

2012-06-11 Thread Nick Coghlan
Changes by Nick Coghlan ncogh...@gmail.com: -- assignee: - ncoghlan stage: needs patch - patch review ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue13857 ___

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

2012-06-11 Thread Roundup Robot
Roundup Robot devn...@psf.upfronthosting.co.za 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

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

2012-06-11 Thread Nick Coghlan
Nick Coghlan ncogh...@gmail.com 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

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

2012-06-11 Thread Nick Coghlan
Changes by Nick Coghlan ncogh...@gmail.com: -- resolution: - fixed stage: patch review - committed/rejected status: open - closed ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue13857 ___

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

2012-05-29 Thread Nick Coghlan
Nick Coghlan ncogh...@gmail.com 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. --

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

2012-05-29 Thread R. David Murray
R. David Murray rdmur...@bitdance.com 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

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

2012-05-29 Thread Chris Jerdonek
Chris Jerdonek chris.jerdo...@gmail.com 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 rep...@bugs.python.org

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

2012-05-29 Thread R. David Murray
R. David Murray rdmur...@bitdance.com 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. -- ___

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

2012-05-29 Thread Nick Coghlan
Nick Coghlan ncogh...@gmail.com 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-12 Thread Chris Jerdonek
Chris Jerdonek chris.jerdo...@gmail.com 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

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

2012-05-12 Thread Chris Jerdonek
Chris Jerdonek chris.jerdo...@gmail.com 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

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

2012-04-22 Thread Michael . Elsdörfer
Changes by Michael.Elsdörfer mich...@elsdoerfer.info: -- nosy: +elsdoerfer ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue13857 ___ ___

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

2012-02-19 Thread Vladimir Rutsky
Changes by Vladimir Rutsky altsy...@gmail.com: -- nosy: +rutsky ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue13857 ___ ___ Python-bugs-list

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

2012-02-02 Thread Georg Brandl
Georg Brandl ge...@python.org 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-02-02 Thread Ezra Berch
Ezra Berch ezrabe...@mac.com 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). -- ___

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

2012-01-30 Thread Justin Wehnes
Justin Wehnes jweh...@gmail.com added the comment: Just wondering if someone is already working on this or am I free to supply a patch? -- nosy: +jwehnes ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue13857

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

2012-01-30 Thread Nick Coghlan
Nick Coghlan ncogh...@gmail.com 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

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

2012-01-30 Thread Ezra Berch
Ezra Berch ezrabe...@mac.com 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

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

2012-01-29 Thread Georg Brandl
Georg Brandl ge...@python.org added the comment: BTW, the short spelling looks like it wouldn't indent the first line. -- nosy: +georg.brandl ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue13857

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

2012-01-29 Thread Georg Brandl
Georg Brandl ge...@python.org added the comment: Otherwise +1. -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue13857 ___ ___ Python-bugs-list

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

2012-01-25 Thread Nick Coghlan
Nick Coghlan ncogh...@gmail.com 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 rep...@bugs.python.org

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

2012-01-25 Thread Amaury Forgeot d'Arc
Amaury Forgeot d'Arc amaur...@gmail.com 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 rep...@bugs.python.org

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

2012-01-25 Thread Nick Coghlan
Nick Coghlan ncogh...@gmail.com 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

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

2012-01-25 Thread Jon Brandvein
Jon Brandvein jon.brandv...@gmail.com 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

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

2012-01-24 Thread Nick Coghlan
New submission from Nick Coghlan ncogh...@gmail.com: 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