thomas at xs4all.net
Sun May 27 20:27:14 CEST 2001
On Sun, May 27, 2001 at 10:52:59AM -0700, Ken Peek wrote:
> Python allows the use of spaces or tabs (but not both!) to indent with.
Actually, it does allow mixing tabs and spaces, both in the horizontal and
the vertical sense:
both work fine.
> I think this was a mistake.
You're not the only one. Though ...
> I think tabs should be forced at the beginning of lines, and spaces should
> be forced after the first printable character is typed. The exception to
> this rule would be an empty line, and multiline strings.
... I do think you're the first to propose exactly this. Why should
multiline strings be exempted from this rule ? (Note: the *contents* of a
multiline string literals aren't considered in indents/dedents, so that is
never an issue.)
> This indentation strategy would then be enforced by the interpreter/compiler.
Too late. The Official Python Python Style (used in the std. Python library)
already states an indent is four spaces, and tabs are outlawed. The Official
Python C Style uses tabs for indentation, though.
> This will allow the programmer to set their editor to display a tab at
> whatever indentation spacing they like, and the original structure (which
> is part of the documentation of the code) is preserved.
No, no, no! Tabs are 8 spaces. Eight. Spaces. Always. Setting it to anything
else is Lunacy! Sure to screw you over, or at least *someone*, sooner or
later. If you want to re-indent, your editor can re-indent the code in
whatever way you wish, though I would vote against it. Or you can use Tim's
lifework, 'tabnanny.py', to do it for you. Personally, for Python code, I
think 8 space indents (or single tab indents, if you prefer) are too big:
Python code is generally small and concise, lets keep it that way :)
> Forcing tabs on the beginning of lines, and forcing spaces (for white space)
> after the first printable character (except for null lines and multiline
> strings) would be consistent with the philosophy of forcing "highly readable"
> code to be generated.
Why wouldn't comments be allowed to contain tabs ? Or, say, 'verbose' mode
regular expressions with 'embedded' comments -- or even without comments.
You generally want to outline them properly, and that's what tabs are for,
Thomas Wouters <thomas at xs4all.net>
Hi! I'm a .signature virus! copy me into your .signature file to help me spread!
More information about the Python-list