Question about indentation and bugs
Bengt Richter
bokr at accessone.com
Sun Aug 26 01:40:01 EDT 2001
On Sat, 25 Aug 2001 17:12:36 -0500, Skip Montanaro <skip at pobox.com> wrote:
[...]
>
>You're talking about two different things. The standard indentation is four
>spaces, but if you treat a TAB character as eight spaces you'll be okay
>(though with "python -t" you might get some indentation warnings). It's
>when you treat a TAB character as something other than 8 spaces that mixing
>spaces and TABs becomes a problem.
>
You don't literally mean that '\t' becomes ' '*8 ??
I would hope that indent position is calculated using
what the screen display normally uses, ie., if columns
are 0-79, a tab from column c goes to (c&~7)+8, so, e.g.,
four spaces plus a tab at the beginning of a line should
be equivalent to 8 spaces of indent, not 12.
Ugh, I just tried this with python in an interactive NT
console window (which tabs 8):
(I've put in spaces to preserve the way it looked)
>>> def z():
... print 'tabbed indent'
... print '8-space indent'
...
>>> z()
tabbed indent
8-space indent
>>>
^--(col 0)
That's ugly. IMHO indentation that looks aligned ought to act aligned,
irrespective of tab/space mix. For interactive mode, couldn't you
just read the indentation mixed white space characters, prefix 4 space
characters, process tabs like the console, and then subtract 4 from
the resulting final indent column?
More information about the Python-list
mailing list