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 difference
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
Do
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
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
spaces.
E.g.
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 can
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
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.:
input = ' ' + '\t'
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' +
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 probably just as easy
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()
'alpha
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
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 beta'
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), \t)
Of
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,
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 going
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 isn't
16 matches
Mail list logo