Python Rambling

Oct 19th 2008
in
by Lasse Hassing

I have been studying python over the last couple of weeks while working on a small website with web.py. Web.py is great. It has the freedom of PHP but without the annoyance of, well, PHP. I used to think the whole whitespace-thing was crazy. But after running into a lot of the following indentation style at work I changed my mind:

  if($a == $b) {
for($i=0;$i<10;i++) {
$c += $i; } }
          else
    {
$c = 0;
        }

It doesn’t take long to get used to the indentation concept and it really does help keep code readable. Python seem to work for both constructing large OOP projects and for making quick, simple hacks. Like project euler #16: sum([int(x) for x in str(2**1000)]).

There is one major downside I’ve noticed. Python projects seem to have worse documentation than most. But it could just be that I still haven’t figured out the pythonic documentation concept. I am using web.py and SQLObject. The documentation for web.py is weird mix of the stable (0.23) and development (0.30) branch. SQLObject just seems to be a bunch of notes (and a wiki that I’ve only been able to find through 3rd party tutorials). I am especially missing the SQLObject documentation because of all the inheritance “magic”. It is sometimes hard to figure out what class you are dealing with and which methods are available.

But it is a small price to pay for the ability to fly.