Python fits in my brain – no accident

One of the things I like about Python is the way I can hold so much more in my brain without having to look stuff up. If you know the tools for working with sequences (strings, lists, tuples, dictionaries etc), you know what to do with anything that is a sequence. Data from a database can be handled using the standard tools for processing lists and tuples etc etc etc. You don’t need to know how ADO differs from DAO etc. This is no accident – it was by design. Anyway, it was nice to see that a prominent programmer feels the same way about Python:

Bruce Eckel: They say you can hold seven plus or minus two pieces of information in your mind. I can’t remember how to open files in Java. I’ve written chapters on it. I’ve done it a bunch of times, but it’s too many steps. …

The other issue is the effect of an interruption. If you are really deep into doing something and you have an interruption, it’s quite a number of minutes before you can get back into that deeply focused state. With programming, imagine you’re flowing along. You’re thinking, “I know this, and I know this, and I know this,” and you are putting things together. And then all of a sudden you run into something like, “I have to open a file and read in the lines.” All the clutter in the code you have to write to do that in Java can interrupt the flow of your work.

Another number that used to be bandied about is that programmers can produce an average of ten working lines of code per day. Say I open up a file and read in all the lines. In Java, I’ve probably already used up my ten working lines of code for that day. In Python, I can do it in one line. I can say, “for line in file(‘filename’).readlines():,” and then I’m ready to process the lines. And I can remember that one liner off the top of my head, so I can just really flow with that.