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


Groups > comp.lang.python > #10844

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

References <001201cc525e$8f834510$ae89cf30$@com.au>
Date 2011-08-04 00:08 -0700
Subject Re: Inconsistencies with tab/space indentation between Cygwin/Win32?
From Chris Rebert <clp2@rebertia.com>
Newsgroups comp.lang.python
Message-ID <mailman.1879.1312441712.1164.python-list@python.org> (permalink)

Show all headers | View raw


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

Back to comp.lang.python | Previous | Next | Find similar | Unroll thread


Thread

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

csiph-web