Tabs and spaces (style)

Ken Seehof kens at sightreader.com
Tue May 1 18:22:30 EDT 2001


Most people seem to be using spaces only, with indentation of 4.
This is popular for those of us with a real code editor.

"All tabs" is the next most popular, especially for people writing
python on a Kaypro. :-)

Hey Guido, please change your style guide ok?  Mixing tabs
and spaces is lame, and fortunately nobody does it anyway :-)

Here's some data:

spc  tab  gvr  nmix
102   32   0   8   c:\python20\lib
  1   15    0    0  ...\Pythonwin\pywin\framework
  2    8    0    0   ...\Pythonwin\pywin\scintilla
31    0    0    0   C:\Python20\wxPython
  2    7    0    0  C:\Python20\win32\demos
  1    5    0    6  C:\Python20\win32com\client
 23    0    0    0  C:\Python20\_xmlplus\dom
  2   17    0    0  D:\qp\WebQ\QServer\medusa
  5    0    0    0  C:\Python20\Orchard-python-0.3.1\Orchard
  8    1    1*    2  C:\Python20\OpenGL\Demo\srenner
  8    3    0    2  C:\Python20\OpenGL\Demo\tom
 44    1    0    1  C:\Python20\Tools\idle

spc = uses spaces only (usually 4 spaces)
tab = uses tabs only
gvr = uses Guidos suggested tab8+space4 combo
nmix = mixes tabs and spaces sloppily (at least 3 lines of each)

(* actually, on inspection, trees.py is a sloppy mix of
spaces and tabs, not gvr style.)

----------------------------------------------------
Copyright (c) 2001 by Ken Seehof
This document may not be distributed, copied,
duplicated, or replicated, or duplicated in any
form without express permission by Ken Seehof.
Permission is hereby granted.
kseehof at neuralintegrator.com
----------------------------------------------------
The opinions expressed herein are not necessarily
those of George W. Bush.

Alex Martelli says:
> "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.

Fortunately most Pythonistas do not 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)...

Yay.  Most Pythonistas follow your style.

> 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

-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: tabcheck.py
URL: <http://mail.python.org/pipermail/python-list/attachments/20010501/55eb8112/attachment.ksh>


More information about the Python-list mailing list