[Pythonmac-SIG] Indentation Styles
Chris Barker
cbarker@jps.net
Mon, 27 Nov 2000 15:10:44 -0800
Francois Granger wrote:
> For foreign script I receive, either they run "out of the box", or,
> if I need to edit them, I first do a search and replace of spaces for
> tab before editing. I uses Pepper
> <http://www.hekkelman.com/pepper.html> as my main editor.
Be Careful! If you do that search and replace with a file that has mixed
spaces and tabs, you will get a real mess! That's why I use the script
that I posted earlier to convert my files. It uses the Python tokenizer
to interpret the indenting, so I am guaranteed to get the same thing
that the interpreter would get.
As Jack said, using spaces is harder than tabs, at least on the Mac.
What we need are smarter editors. Pepper has promise. I'd like to see
what it can do with the space/tab thing. On Linux, I use emacs, and
emacs python-mode can be set to put in tabs, spaces, or a mixture. It
used to be that the mixture was the default, which is why so many files
had it! In all the language modes Ive used with emacs, the tab key is
mapped to the "indent this line" function, and the delete key gets
mapped to "remove one level of indentation" when it's in the whitespace
at the beginning of a line. This level of abstraction makes it easy to
use any indentation style you want. So, while it still seems silly to
use four bytes where one would do, it is not any harder to do, if you
have a smart enough editor. Are any Mac editors smart enough to be set
up to be used this way? I'd love to have that.
-Chris
--
Christopher Barker,
Ph.D.
cbarker@jps.net --- --- ---
http://www.jps.net/cbarker -----@@ -----@@ -----@@
------@@@ ------@@@ ------@@@
Water Resources Engineering ------ @ ------ @ ------ @
Coastal and Fluvial Hydrodynamics ------- --------- --------
------------------------------------------------------------------------
------------------------------------------------------------------------