Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #10844 > unrolled thread

Re: Inconsistencies with tab/space indentation between Cygwin/Win32?

Started byChris Rebert <clp2@rebertia.com>
First post2011-08-04 00:08 -0700
Last post2011-08-04 00:08 -0700
Articles 1 — 1 participant

Back to article view | Back to comp.lang.python

This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by below is the oldest one visible, not the original post.


Contents

  Re: Inconsistencies with tab/space indentation between Cygwin/Win32? Chris Rebert <clp2@rebertia.com> - 2011-08-04 00:08 -0700

#10844 — Re: Inconsistencies with tab/space indentation between Cygwin/Win32?

FromChris Rebert <clp2@rebertia.com>
Date2011-08-04 00:08 -0700
SubjectRe: Inconsistencies with tab/space indentation between Cygwin/Win32?
Message-ID<mailman.1879.1312441712.1164.python-list@python.org>
On Wed, Aug 3, 2011 at 9:25 PM, Christian Gelinek
<cgelinek@radlogic.com.au> wrote:
> Hi all,
>
> I have a problem running some python program using version 2.6.4 (or version
> 2.7.2, I tried both) from the Win7 command line - it never finishes due to
> an infinite loop. The thing is, when I run the same program through Cygwin
> which uses Python version 2.6.5, it exits the loop at some point.
>
> I came to try this after I realised that in some of the sources (it is a
> rather big program using many source files, most of them being created by
> others from a Linux environment), the indentation is mixed tabs/spaces where
> the assumed tab size is 8 spaces.

That's just plain evil.

> Reading on the Python website, a tab size of 8 is default anyway, so I would
> have assumed it should work... does that mean that one tab equals 2
> indents?!? I myself never use tabs to indent Python code but let my editor
> do a tab-to-4-spaces conversion when I press <TAB>.
>
> I find it at least confusing to read that Python expects a tab size of 8 but
> at the same time uses 4 spaces for one indent level. Or maybe I am
> completely on the wron track here?

4-space indents are /recommended/ by PEP 8, but the interpreter does
not require or prefer that style. What the interpreter does when
parsing indentation is rather more complicated; see
http://docs.python.org/reference/lexical_analysis.html#indentation

You might wanna look at tabnanny:
http://docs.python.org/library/tabnanny.html

Cheers,
Chris

[toc] | [standalone]


Back to top | Article view | comp.lang.python


csiph-web