Re: textwrap.dedent replaces tabs?

2006-12-29 Thread Tom Plunket
OKB (not okblacke) wrote: > > (You dedent common leading tabs, except if preceded by common leading > > spaces (?)). > > There cannot be common leading tabs if they are preceded by > anything. If they were preceded by something, they wouldn't be > "leading". Right, but 'common leading w

Re: textwrap.dedent replaces tabs?

2006-12-29 Thread OKB (not okblacke)
Frederic Rentsch wrote: > (You dedent common leading tabs, except if preceded by common leading > spaces (?)). There cannot be common leading tabs if they are preceded by anything. If they were preceded by something, they wouldn't be "leading". -- --OKB (not okblacke) Brendan Barnwell

Re: textwrap.dedent replaces tabs?

2006-12-29 Thread Frederic Rentsch
Tom Plunket wrote: > Frederic Rentsch wrote: > > >> Your rules seem incomplete. >> > > Not my rules, the stated documentation for dedent. "My" understanding > of them may not be equivalent to yours, however. It's not about understanding, It's about the objective. Let us consider the diffe

Re: textwrap.dedent replaces tabs?

2006-12-28 Thread Tom Plunket
Frederic Rentsch wrote: > Your rules seem incomplete. Not my rules, the stated documentation for dedent. "My" understanding of them may not be equivalent to yours, however. > What if common tabs remain after stripping common white space? What if we just go with, "[r]emove any whitespace than c

Re: textwrap.dedent replaces tabs?

2006-12-28 Thread Frederic Rentsch
Tom Plunket wrote: > Frederic Rentsch wrote: > > >> It this works, good for you. I can't say I understand your objective. >> (You dedent common leading tabs, except if preceded by common leading >> spaces (?)). >> > > I dedent common leading whitespace, and tabs aren't equivalent to > spa

Re: textwrap.dedent replaces tabs?

2006-12-25 Thread Tom Plunket
Frederic Rentsch wrote: > It this works, good for you. I can't say I understand your objective. > (You dedent common leading tabs, except if preceded by common leading > spaces (?)). I dedent common leading whitespace, and tabs aren't equivalent to spaces. E.g. if some text is indented exclusi

Re: textwrap.dedent replaces tabs?

2006-12-24 Thread Frederic Rentsch
Tom Plunket wrote: > Frederic Rentsch wrote: > > >> Following a call to dedent () it shouldn't be hard to translate leading >> groups of so many spaces back to tabs. >> > > Sure, but the point is more that I don't think it's valid to change to > tabs in the first place. > > E.g.: > > inpu

Re: textwrap.dedent replaces tabs?

2006-12-23 Thread Tom Plunket
Frederic Rentsch wrote: > Following a call to dedent () it shouldn't be hard to translate leading > groups of so many spaces back to tabs. Sure, but the point is more that I don't think it's valid to change to tabs in the first place. E.g.: input = ' ' + '\t' + 'hello\n' + '\t' + 'wo

Re: textwrap.dedent replaces tabs?

2006-12-22 Thread Frederic Rentsch
Tom Plunket wrote: > Frederic Rentsch wrote: > > >>> Well, there is that small problem that there are leading tabs that I >>> want stripped. I guess I could manually replace all tabs with eight >>> spaces (as opposed to 'correct' tab stops), and then replace them when >>> done, but it's probabl

Re: textwrap.dedent replaces tabs?

2006-12-18 Thread Tom Plunket
Frederic Rentsch wrote: > > Well, there is that small problem that there are leading tabs that I > > want stripped. I guess I could manually replace all tabs with eight > > spaces (as opposed to 'correct' tab stops), and then replace them when > > done, but it's probably just as easy to write a n

Re: textwrap.dedent replaces tabs?

2006-12-18 Thread Tom Plunket
Peter Otten wrote: > > I guess I could manually replace all tabs with eight > > spaces (as opposed to 'correct' tab stops), and then replace them when > > done, but it's probably just as easy to write a non-destructive dedent. > > You mean, as easy as > > >>> "\talpha\tbeta\t".expandtabs() > '

Re: textwrap.dedent replaces tabs?

2006-12-17 Thread Frederic Rentsch
Tom Plunket wrote: > CakeProphet wrote: > > >> Hmmm... a quick fix might be to temporarily replace all tab characters >> with another, relatively unused control character. >> >> MyString = MyString.replace("\t", chr(1)) >> MyString = textwrap.dedent(MyString) >> MyString = MyString.replace(chr(1

Re: textwrap.dedent replaces tabs?

2006-12-17 Thread Peter Otten
Tom Plunket wrote: > I guess I could manually replace all tabs with eight > spaces (as opposed to 'correct' tab stops), and then replace them when > done, but it's probably just as easy to write a non-destructive dedent. You mean, as easy as >>> "\talpha\tbeta\t".expandtabs() 'alpha be

Re: textwrap.dedent replaces tabs?

2006-12-16 Thread Tom Plunket
CakeProphet wrote: > Hmmm... a quick fix might be to temporarily replace all tab characters > with another, relatively unused control character. > > MyString = MyString.replace("\t", chr(1)) > MyString = textwrap.dedent(MyString) > MyString = MyString.replace(chr(1), "\t") > > Of course... this

Re: textwrap.dedent replaces tabs?

2006-12-16 Thread CakeProphet
Hmmm... a quick fix might be to temporarily replace all tab characters with another, relatively unused control character. MyString = MyString.replace("\t", chr(1)) MyString = textwrap.dedent(MyString) MyString = MyString.replace(chr(1), "\t") Of course... this isn't exactly safe, but it's not goi

textwrap.dedent replaces tabs?

2006-12-16 Thread Tom Plunket
The documentation for dedent says, "Remove any whitespace than can be uniformly removed from the left of every line in `text`", yet I'm finding that it's also modifying the '\t' characters, which is highly undesirable in my application. Is there any way to stop it from doing this, or alternatively