Main Content

Python is like a narrowboat

Archive - Originally posted on "The Horse's Mouth" - 2006-10-30 15:25:55 - Graham Ellis

I'm giving a Python course today, to a team of seasoned programmers, and of course I'm coming up with a few things that are different to the languages they know. So far, we've had ...

* No switch statement
* No ++ operator
* blocks indicated via insets
* else clauses on while loops

Of course, this makes them a little nervous, although it will turn out later on that the facilities that aren't present wouldn't be at all vital in Python, and indeed they may encourage poor coding practise. And block insets and extra "elses" are so natural once people are use to that way of doing things.

But people still aren't always convinced. "What do you drive?" I ask them. "A Ford" they say (or something else). "If you switched to a Vauxhall, would it be easy?" I ask. "Not necessarily - things will be in different places ..." is the answer but, yes, they would get used to the Vauxhall positioning in time.

Actually, Python can be very different. I used to drive a narrowboat quite regularly, and that's the complete opposite of driving a car - push the tiller to the right to go left for starters, and then remember that the boat takes a while to react as you're not controlling types straight onto the ground, but rather you're changing the direction via the water. Ah - but once you've driven a boat a few times you find there's a great natural beauty in it, and in the way it works. 8 tons can be controlled by just a gentle push with a single finger - much more efficient even that your car. Yes, that's a good description of the beauty and efficiency of Python too - Python is like a narrowboat.