People who want to see 4-space indentation on Unix may have no choice
but to mix spaces and tabs -- most editors' auto-indent mode optimizes
8 spaces into a tab.
My recommendation is to always use tabs on the Mac -- then it will
look good on the Mac and at least parse correctly everywhere.
For the same reason I recommend always using tabs on Unix as well
(thus indenting by 8 positions there), but the majority of Python
users seem to be against me.
Note that the Mac code contains a hack which attempts to get the tab
size from an editor "ETAB" resource but I don't know how succesful
this is since there are many different editors around... (Code
attached, comments welcome.)
--Guido van Rossum, CWI, Amsterdam <Guido.van.Rossum@cwi.nl>
URL: <http://www.cwi.nl/cwi/people/Guido.van.Rossum.html>
======================= macguesstabsize.c =======================
#include <MacHeaders>
#include <string.h>
/* Interface used by tokenizer.c */
guesstabsize(path)
char *path;
{
char s[256];
int refnum;
Handle h;
int tabsize = 0;
s[0] = strlen(path);
strncpy(s+1, path, s[0]);
refnum = OpenResFile(s);
/* printf("%s --> refnum=%d\n", path, refnum); */
if (refnum == -1)
return 0;
UseResFile(refnum);
h = GetIndResource('ETAB', 1);
if (h != 0) {
tabsize = (*(short**)h)[1];
/* printf("tabsize=%d\n", tabsize); */
}
CloseResFile(refnum);
return tabsize;
}
=================================================================