Python and Apache
Subject:   In defence of Python...
Date:   2003-04-11 03:21:07
From:   anonymous2
OK I'll bite. In defence of Python...

"If you change the ordering of the code you have to change the indentation on every line affected, rather than just moving the end braces."

You have to do that with code written in other languages anyway. If you change the ordering of the code you're going to have to reindent things or your indentation will just be confusing. Every decent programmer I've ever met has indented their code, Python just makes that behaviour part of the language. It ends up being a LOT easier to spot problems due to indentation compared to spotting problems in a brace-denoted language due to a missing brace somewhere.

The indentation thing always crops up when people not used to it take a look at Python. The simple answer is to give it a go - it's remarkably intuitive once you get over the initial shock (I can remember being put off by indentation before I tried Python).

To be fair though, you do need a half decent editor to effectively work with Python. My editor can add / subtract 4 spaces of indentation from a selected block of code when I hit tab / shift-tab. I can't imagine there are many programmer's editors out there that lack this functionality.

"Is Python the language for a first-timer? I'm not sure. It is a solid piece of work, properly organized and developed, and is, happily, without some of the annoying quirks of Perl. On the other hand, its odd indentation syntax is unlike any other language, so you will eventually have to unlearn it."

There's a sizeable movement to get Python more involved in education, and I'm a big supporter of the idea. Python has a very shallow learning curve, teaches good programming practise from the start (proper indentation for one thing) and covers a whole bunch of different programming paradigm. My girlfriend was struggling with Java so I introduced her to Python and she picked it up in less than a week and found her understanding of Java improving as well. The fact that hello world is:

print "hello world"

Is a big bonus as well.

"I get the impression it is not much used for CGI scripts, so although it will probably work (as it does above), it may lack some of the bells and whistles other languages offer."

It's true that it's not used for CGI scripts that much, mainly because mod_python is not yet as stable as mod_perl. Python's indentation rules also make it less of a likely candidate for embedding in HTML, although there are projects that have managed to do this.

As for bells and whistles, take a look at the Python Standard Library :) There aren't many languages that come with modules for ftp, smtp, imap, SGML parsing, DOM and SAX XML, unit testing, building HTTP servers and so on straight out of the box. In fact there are very few bells and whistles that Python /doesn't/ offer.

This post was not intended as a rant, more of an informative overview of details the author may have missed in his brief inspection of Python.