Python indentation deters newbies?
tjreedy at udel.edu
Fri Aug 13 22:27:30 CEST 2004
<beliavsky at aol.com> wrote in message
news:3064b51d.0408130615.3fc4a760 at posting.google.com...
> One of the most commmon reasons programmers cite for not trying Python
I suspect that the main barrier is hearing or reading enough about Python
to serious think about trying it.
> is that indentation determines the program flow -- they think its weird.
Giving that structured text (in English at least) routinely uses
significant indentation (lists, outlines, block quotes) and that much
algorithm pseudocode does the same (which was half the reason I called
Python 'executable pseudocode'), I find it puzzling that so many find it
'weird' (if indeed that is true).
> I wonder if there is a way to remove this initial barrier.
Perhaps better explanation in the introductory materials might help. Do
you have any suggestions?
> Could an alternate source form be defined,
'Could' ? of course. And you are free to do so, and to write a
preprocessor that converts the alternate form to standard Python, and even
to distribute an intepreter that has it builtin, and even to promote
FencePy as a 'Python variant for beginners' or as 'Transitional Python for
> so that there are matching if-endif
> and for-next constructs instead of significant indentation?
If a block is too long to easily match indentation levels, I myself might
add an unofficial '#end if xyz' (properly dedented) to help readers
(including possibly myself in the future) visually and mentally close the
block. The downside though is to make editing possibly slightly harder.
> The alternate source form and the current form would result in exactly
> same .pyc file.
What if the fences and indentation disagreed?
> I'm not saying that Python's use of indentation is bad,
I say that Python's use of indentation is good.
> just that it stops many programmers from trying it.
Perhaps. But it encourages others to try and adopt it and it is a key part
of making Python code unusually readable, which was and is one of its main
Terry J. Reedy
More information about the Python-list