Little red lines in PythonWin!

David Bolen db3l at fitlinxx.com
Tue Mar 20 14:49:14 EST 2001


"Bill Bell" <bill-bell at bill-bell.hamilton.on.ca> writes:

> What, in general, do you guys do about distributing sourcecodes in 
> a language like Python that depends on indenting and where tabs 
> can cause chaos. (And, no, you can't possibly shoot all of those of 
> us who get caught this way, so that's not a solution.)
> 
> Please point me towards the accepted approach. Thanks.

The safest and most robust approach is probably just to untabify
anything that is going to be released to the public, to minimize the
potential for confusion.  How to do that differs by tool (most editors
support the idea, e.g., M-x untabify in Emacs, and I'm sure there are
standalone utilities around via a quick web search).

In theory you really shouldn't get into trouble using tabs as long as
you follow Python's parser definition of what a tab is (treat as
moving to next multiple of 8 - Language Reference 2.1.7).  The trouble
is mostly when an editor is using an explicit tab character but
internally adjusting its dimension to something other than that rule.
Even that might work as long as only tabs are used for indentation,
but if spaces get mixed in it's bound to cause problems.  So in
general that's nasty, but as long as you untabify in that same
editor/IDE before distribution, since it knows its own rules, the
untabified version should be fine.

Of course, not using tabs (or definitely not mixing tabs and spaces)
in the source is probably best, given prior experience with confusion
on how to handle them compatibly cross-toolsets.  Most editors and
IDEs will let you configure such that pressing the TAB key indents you
appropriately, but is really using spaces to do so.

--
-- David
-- 
/-----------------------------------------------------------------------\
 \               David Bolen            \   E-mail: db3l at fitlinxx.com  /
  |             FitLinxx, Inc.            \  Phone: (203) 708-5192    |
 /  860 Canal Street, Stamford, CT  06902   \  Fax: (203) 316-5150     \
\-----------------------------------------------------------------------/



More information about the Python-list mailing list