Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #10880
| Path | csiph.com!x330-a1.tempe.blueboxinc.net!usenet.pasdenom.info!weretis.net!feeder4.news.weretis.net!ecngs!feeder2.ecngs.de!zen.net.uk!hamilton.zen.co.uk!reader02.news.zen.co.uk.POSTED!not-for-mail |
|---|---|
| From | Nobody <nobody@nowhere.com> |
| Subject | Re: Inconsistencies with tab/space indentation between Cygwin/Win32? |
| Date | Thu, 04 Aug 2011 22:35:02 +0100 |
| User-Agent | Pan/0.14.2 (This is not a psychotic episode. It's a cleansing moment of clarity.) |
| Message-Id | <pan.2011.08.04.21.35.01.55000@nowhere.com> |
| Newsgroups | comp.lang.python |
| References | <mailman.1875.1312432561.1164.python-list@python.org> |
| MIME-Version | 1.0 |
| Content-Type | text/plain; charset=UTF-8 |
| Content-Transfer-Encoding | 8bit |
| Lines | 37 |
| Organization | Zen Internet |
| NNTP-Posting-Host | a966e162.news.zen.co.uk |
| X-Trace | DXC=oP=njFR4VHaWTR[NRY=YacYjZGX^207Pk`<MJMoM3PFm^fGOZ1i9_:fNQ<`Sf8^TaockQ_X@ER0igO^>2jRX?:Ui |
| X-Complaints-To | abuse@zen.co.uk |
| Xref | x330-a1.tempe.blueboxinc.net comp.lang.python:10880 |
Show key headers only | View raw
On Thu, 04 Aug 2011 13:55:37 +0930, Christian Gelinek wrote: > 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-column indents are a convention, not a rule. You can use however many columns you like, and you don't even need to be consistent about it; you can use 2 columns for one "block" and 4 columns for another. Python only cares about "indented more than the previous line" and "indented to a depth matching an outer level of the code". 8-column tab stops are a rule, due to it being such a long-standing convention that some software and hardware has 8-column tab stops hardwired (and anything which allows tab stops to be configured normally defaults to 8 columns). > Any ideas on how to get the thing to run under (real) Windows, hopefully > without having to edit existing sources of people who left our company ages > ago? The only time you'll have problems is if you copy-and-paste code which was written using a mix of tabs and spaces and which assumed a different tab width. If code only ever uses tabs, the tab width doesn't matter. If code uses a mix of tabs and spaces and it actually works, it's correct according to Python's 8-column tab stops, even if that's not how the programmer's editor was set up. Also, copying blocks of code which start and end at the top-level (i.e. without indentation) will work regardless. Where it fails is if you copy indented code from e.g. a file which used a mix of spaces and 4-column tabs into a file which uses 8-column tabs. If you have existing code which uses a mix of tabs and spaces where tabs aren't 8 columns (or you aren't sure that they're 8 columns), your best bet is to reformat the code to avoid using tabs (on Unix: "pr -t -e", or "pr -t -e4" for 4-column tabs).
Back to comp.lang.python | Previous | Next — Previous in thread | Find similar | Unroll thread
Inconsistencies with tab/space indentation between Cygwin/Win32? "Christian Gelinek" <cgelinek@radlogic.com.au> - 2011-08-04 13:55 +0930 Re: Inconsistencies with tab/space indentation between Cygwin/Win32? Thorsten Kampe <thorsten@thorstenkampe.de> - 2011-08-04 07:18 +0200 Re: Inconsistencies with tab/space indentation between Cygwin/Win32? Nobody <nobody@nowhere.com> - 2011-08-04 22:35 +0100
csiph-web