The Artima Developer Community
Sponsored Link

Weblogs Forum
Myths About Indentation in Python

21 replies on 2 pages. Most recent reply: Oct 28, 2009 3:10 PM by Jame Krall

Welcome Guest
  Sign In

Go back to the topic listing  Back to Topic List Click to reply to this topic  Reply to this Topic Click to search messages in this forum  Search Forum Click for a threaded view of the topic  Threaded View   
Previous Topic   Next Topic
Flat View: This topic has 21 replies on 2 pages [ « | 1 2 ]
Kay Schluehr

Posts: 302
Nickname: schluehk
Registered: Jan, 2005

Re: Myths About Indentation in Python Posted: Sep 28, 2007 10:00 PM
Reply to this message Reply
Advertisement
> No, not at all. If two programmers modify the same code
> file at the same time and one indents such code, you can
> end up with new code merged at the wrong indentation.

But only if the merge is purely textual without any knowledge about how to handle two *.py files. I think the situation is somewhat comparable to syntax highlighting capabilities of modern source code editors. You only realize it, when it is lacking in applications like MS Notepad.

Vincent O'Sullivan

Posts: 724
Nickname: vincent
Registered: Nov, 2002

Re: Myths About Indentation in Python Posted: Sep 28, 2007 11:37 PM
Reply to this message Reply
> Why not take it to it's logical
> conclusion?

Whitespace taken to its logical conclusion...

http://compsoc.dur.ac.uk/whitespace/

Kay Schluehr

Posts: 302
Nickname: schluehk
Registered: Jan, 2005

Re: Myths About Indentation in Python Posted: Sep 29, 2007 12:25 AM
Reply to this message Reply
> > Why not take it to it's logical
> > conclusion?
>
> Whitespace taken to its logical conclusion...
>
> http://compsoc.dur.ac.uk/whitespace/

But the spec leaves open the question what takes over the role of Pythons whitespace in the Whitespace language?

Note that Guido already blogged about sticter whitespace enforcment - but you know this because you responded in the comments thread :)

http://www.artima.com/weblogs/viewpost.jsp?thread=101968

Guido van van Rossum

Posts: 359
Nickname: guido
Registered: Apr, 2003

Re: Myths About Indentation in Python Posted: Sep 29, 2007 11:24 AM
Reply to this message Reply
> > How in the world can whitespace which enforces
> > uniformity be labeled a `trap`?
>
> Just look at the answers to the traps and pitfalls
> (mislabeled as "myths"):
>
> "No, not in general ..."
> "Yes and no ..."
> "That's right, and you don't want that ..."

Oh cool, a flame war! :-)

Please take this to slashdot, where it belongs.

Petr Mares

Posts: 5
Nickname: dramenbejs
Registered: Feb, 2006

Re: Myths About Indentation in Python Posted: Oct 16, 2007 5:17 PM
Reply to this message Reply
I find another advantage in significant indentation -- it teaches the programmer to overcome his prejudices and to accept better styles of doing things without fighting them first.

Daniel Wong

Posts: 2
Nickname: danielx
Registered: Apr, 2005

Re: Myths About Indentation in Python Posted: Oct 27, 2007 6:21 PM
Reply to this message Reply
This article brings up some good points for people who knock Python's indentation without having experienced what a joy they are to work with. I tend to find the most skepticism from those who are steeped in the ways of C style languages and have come to believe the use of curly braces is "the right way" to delimit blocks. In my case, my love for Python is really a reaction against C style languages, which are oblivious to the fact that humans have a difficult time matching braces but have no trouble at all interpreting indentation. That's why good C style include consistent indentation. My point is, if authors are already taking on the responsibility of ensuring good indentation, why add the burden of also ensuring proper bracing?

While I'm sure there are many articles that expound on the virtues of Python's indentation, this article does not do much to address those benefits. That's somewhat disappointing to me because the use of indentation was one of the reasons I fell in love with Python in the first place. If I were trying to sell Python to a friend who seemed to be stuck on the use of indentation in Python, I would first argue for the benefits of indentation vs. matched delimiters. Then, I would make the points brought up in this article.

Jame Krall

Posts: 1
Nickname: jamebk
Registered: Oct, 2009

Re: Myths About Indentation in Python Posted: Oct 28, 2009 3:10 PM
Reply to this message Reply
Who figured this out. The code doesn't compile because on indentation that don't exist errors when there are none. TypeError: unbound method IntStop() must be called with Get instance as first argument (got nothing instead) when IntStop is called with Get instance as first argument. Drives me to insanity.

Flat View: This topic has 21 replies on 2 pages [ « | 1  2 ]
Topic: Put a Flex UI On Your Application Previous Topic   Next Topic Topic: Solution Based Modelling - Lost OO Wisdom

Sponsored Links



Google
  Web Artima.com   

Copyright © 1996-2019 Artima, Inc. All Rights Reserved. - Privacy Policy - Terms of Use