Parsing Indented Text (like parsing Python)
ptmcg at austin.rr.com
Sun Mar 11 17:12:20 CET 2007
On Mar 11, 8:37 am, "Gabriel Genellina" <gagsl-... at yahoo.com.ar>
> If you mix tabs+spaces, Python simple replaces each tab by 8 spaces.
Are you sure about this? This is not the tab problem I am familiar
with in the past. In the following sample, the columnar text labeled
'col2' should all be aligned at column 9:
In the first line, the tab is replaced with 7 spaces, the second line
by 5, and the third line by 6. So tab replacement is a bit more
involved than simply "s/\t/ /g".
As I recall, the number of spaces to replace a tab by is something
like 8-(col % 8) where col is the column location of the tab with the
left most column being 0.
More information about the Python-list