Tabs and spaces (style)

Alex Martelli aleaxit at yahoo.com
Tue May 1 15:24:07 EDT 2001


"Cantanker" <az at cantanker.net.nospam> wrote in message
news:Y4AH6.28530$ff.208353 at news-server.bigpond.net.au...
> What is the consensus about mixing tabs and spaces in a Python script?

I don't think there is one.  Guido's style guide recommends using both,
with a tabsize of 8, so I expect most Pythonistas follow that style.

Yet, for what it counts, I personally prefer setting my editors to always
save with spaces only (so _all_ tools will certainly see my source in just
the same way:-) and curse every time somebody posts code using tabs
(which some newsreading software hides completely from me)...

Guido suggests that conversion to all-spaces (useful when a Windows
platform is involved) can be done upon transfer of the source to that
platform.  But that doesn't cover all cases in which transformation tools
may not, or definitely WILL not, be involved, such as disks being shared
via Samba or NFS between heterogeneous platforms, sources that are
zipped or tgz'd and the zipfile or tarball put up for download, etc.  It
seems to me that spaces-only is the only really cross-platform approach.


Alex






More information about the Python-list mailing list