Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Python > indentation

Reply
Thread Tools

indentation

 
 
Ross Ridge
Guest
Posts: n/a
 
      10-20-2008
Bruno Desthuilliers <(E-Mail Removed)> wrote:
>I can't remember having seen any other "standard" so far.


I've seen various indentation styles used in examples on this newsgroup.
No one bothers to complain when I indent using tabs, or someone else
uses 2 space indentation.

Ross Ridge

--
l/ // Ross Ridge -- The Great HTMU
[oo][oo] http://www.velocityreviews.com/forums/(E-Mail Removed)
-()-/()/ http://www.csclub.uwaterloo.ca/~rridge/
db //
 
Reply With Quote
 
 
 
 
Bruno Desthuilliers
Guest
Posts: n/a
 
      10-20-2008
Ross Ridge a écrit :
> Bruno Desthuilliers <(E-Mail Removed)> wrote:
>> I can't remember having seen any other "standard" so far.

>
> I've seen various indentation styles used in examples on this newsgroup.


I meant: in a real-life project.

 
Reply With Quote
 
 
 
 
Ross Ridge
Guest
Posts: n/a
 
      10-20-2008
Bruno Desthuilliers <(E-Mail Removed)> wrote:
> I can't remember having seen any other "standard" so far.
>

Ross Ridge a écrit :
> I've seen various indentation styles used in examples on this newsgroup.


Bruno Desthuilliers <(E-Mail Removed)> wrote:
>I meant: in a real-life project.


So? There's no reason to assume the styles people use on this newsgroup
don't reflect those they use in "real-life" projects.

Ross Ridge

--
l/ // Ross Ridge -- The Great HTMU
[oo][oo] (E-Mail Removed)
-()-/()/ http://www.csclub.uwaterloo.ca/~rridge/
db //
 
Reply With Quote
 
Paul Boddie
Guest
Posts: n/a
 
      10-20-2008
On 20 Okt, 14:24, Duncan Booth <(E-Mail Removed)> wrote:
>
> Those were the only two suggestions given for Python projects with tabs as
> a coding style. I don't know if the first of these has more than 1
> developer, the second lists 7 people as contributors.
>
> So it looks like real-life projects do exist, just not very many or very
> large.


I think Webware uses (or used) tabs exclusively, and that was more
than a seven person project once upon a time.

Paul
 
Reply With Quote
 
Steven D'Aprano
Guest
Posts: n/a
 
      10-20-2008
On Mon, 20 Oct 2008 11:01:19 +0200, Bruno Desthuilliers wrote:

> Steven D'Aprano a écrit :
>> On Sun, 19 Oct 2008 19:03:29 +0200, Bruno Desthuilliers wrote:
>>
>>> Steven D'Aprano a écrit :
>>>
>>> (snip)
>>>
>>>> You can use tabs, or spaces. If you use spaces, you can choose 4
>>>> spaces, or 8, or any number,
>>> By all means, make it 4 spaces - that's the standard.

>>
>> It's *a* standard. I believe it is the standard for the Python standard
>> library, but there are other standards.

>
> I can't remember having seen any other "standard" so far.



How about PEP 8? It's not even hidden deep in the bowels of the PEP --
it's almost at the top.
http://www.python.org/dev/peps/pep-0008/

"For really old code that you don't want to mess up, you can continue to
use 8-space tabs."


Then there's string.expandtabs():

expandtabs(...)
S.expandtabs([tabsize]) -> string

Return a copy of S where all tab characters are expanded using spaces.
If tabsize is not given, a tab size of 8 characters is assumed.


Here's Jamie Zawinski:
http://www.jwz.org/doc/tabs-vs-spaces.html

"On defaultly-configured Unix systems, and on ancient dumb terminals and
teletypes, the tradition has been for the TAB character to mean ``move to
the right until the current column is a multiple of 8.'' (As it happens,
this is how Netscape interprets TAB inside <PRE> as well.) This is also
the default in the two most popular Unix editors, Emacs and vi."


This page is a little old (2002), but it states that the standards for
OpenBSD and Linux (presumably the kernels) are 8 space indents:

http://xarg.net/writing/tabs

Here's a style guide that recommends 2, 3 or 4 space indents:

http://www.cs.bris.ac.uk/Teaching/Re...MS12100/style/


And of course, whenever there's a difference of opinion, we can turn to
the ultimate source of all knowledge: Googlefight! *wink*

http://www.googlefight.com/index.php...GB&word1=tab+8
+spaces&word2=tab+4+spaces

Nearly 50 million hits for "tab 8 spaces" versus a piddly 762 thousand
hits for "tab 4 spaces".



--
Steven
 
Reply With Quote
 
Bruno Desthuilliers
Guest
Posts: n/a
 
      10-20-2008
Ross Ridge a écrit :
> Bruno Desthuilliers <(E-Mail Removed)> wrote:
>> I can't remember having seen any other "standard" so far.
>>

> Ross Ridge a écrit :
>> I've seen various indentation styles used in examples on this newsgroup.

>
> Bruno Desthuilliers <(E-Mail Removed)> wrote:
>> I meant: in a real-life project.

>
> So? There's no reason to assume the styles people use on this newsgroup
> don't reflect those they use in "real-life" projects.


Yes there are. I can give you two:
1/ code editor are usually configured to insert X spaces when hitting
'tab' - which is not necessarily the case for newsreaders. Guess what
happens when someone writes a code snippet directly in his newsreader ?

2/ I sometimes use 2-spaces when posting here to avoid linewraps

!-)
 
Reply With Quote
 
Bruno Desthuilliers
Guest
Posts: n/a
 
      10-20-2008
Duncan Booth a écrit :
> Bruno Desthuilliers <(E-Mail Removed)> wrote:
>
>> Ross Ridge a écrit :
>>> Bruno Desthuilliers <(E-Mail Removed)> wrote:
>>>> I can't remember having seen any other "standard" so far.
>>> I've seen various indentation styles used in examples on this newsgroup.

>> I meant: in a real-life project.
>>
>>

(snip two examples)


> So it looks like real-life projects do exist,


Possibly. I just said that *I* didn't remember having seen such a thing.

 
Reply With Quote
 
Lie Ryan
Guest
Posts: n/a
 
      10-20-2008
On Sun, 19 Oct 2008 07:16:44 -0700, Gandalf wrote:

> every time I switch editor all the script indentation get mixed up, and
> python start giving me indentation weird errors. indentation also hard
> to follow because it invisible unlike brackets { }
>
> is there any solution to this problems?
>
>
>
> thank you!


When in Rome, do like the Romans do.
When coding python in general, use four spaces as described in style
guideline (PEP
However, when the code you're editing doesn't follow the guideline,
follow the code's guideline.

If the code doesn't have a guideline (e.g. the code liberally mix up tabs
and spaces), make one and enforce it.

 
Reply With Quote
 
GHUM
Guest
Posts: n/a
 
      10-20-2008
> I can't remember having seen any other "standard" so far.

there is this meme flowing around:

Thus spake the Lord: Thou shalt indent with four spaces. No more, no
less.
Four shall be the number of spaces thou shalt indent, and the number
of thy
indenting shall be four. Eight shalt thou not indent, nor either
indent thou
two, excepting that thou then proceed to four. Tabs are right out.


I Allways thought that was some of the interpretations of the ZEN of
Python, so, who can enlighten me of the origin?

Harald
 
Reply With Quote
 
Terry Reedy
Guest
Posts: n/a
 
      10-20-2008
Ross Ridge wrote:
> Bruno Desthuilliers <(E-Mail Removed)> wrote:
>> I can't remember having seen any other "standard" so far.
>>

> Ross Ridge a écrit :
>> I've seen various indentation styles used in examples on this newsgroup.

>
> Bruno Desthuilliers <(E-Mail Removed)> wrote:
>> I meant: in a real-life project.

>
> So? There's no reason to assume the styles people use on this newsgroup
> don't reflect those they use in "real-life" projects.


Yes there is. If I type *hypothetical* code for a post, *I* have to
type all the spaces, and I often use 2 per indent level. If I type in
IDLE, *it* adds the spaces (4 per indent) automatically.

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
remove overall indentation preserving reletive indentation Jesse B. Ruby 2 03-27-2010 07:23 PM
DataList Indentation SJ ASP .Net 2 11-04-2005 12:16 AM
[Fwd: Indentation] jacov Java 0 07-22-2004 03:22 PM
List Indentation Jay HTML 5 04-21-2004 02:49 PM
Unwanted indentation Daan HTML 2 12-09-2003 10:09 PM



Advertisments