Becoming multilingual

Today I started learning Python. I picked it because it’s not only one of the hottest languages right now (outside of C#/Mono), but because GRAMPS is written in Python. I haven’t explored this deeply, but I know for a fact that plugins can be written in Python, if the entire program itself is not Python. (Also, it’s named after one of the funniest comedy troupes the world has ever known!) I have chosen “Dive Into Python” as my tutor in this new language.
I found only two things that annoyed me, one was a minor annoyance and one was a tad more annoying. The minor annoyance came from the fact that the author broke nearly 50 years of tradition and didn’t start the book off with a “hello world” tutorial. Yeah, he talks about how he’s not going to bore the reader with all the crap that I always glossed over in the other programming books. I mean, this book truly is what it claims to be – it doesn’t teach you how to program, it teaches you Python. I already know how to program from having taken 2 semesters at Cornell and learned BASIC, Java, C, C++, and a bit of Perl. But to break so many years of tradition! (To be fair to the author, he does type out print ‘hello world’ in the installation chapter, but it’s supposed to be your first program, not the first thing you type into an interactive shell!)

The second annoyance came from the fact that he author never seems to point out how to comment your code! Yet, all you hear about in other books (and college classes) is about how important commenting is. I was only able to find out how to comment because I told Emacs (my editor of choice) to comment out a line. (it’s ##, by the way) Strangely enough, he’s a huge advocate of the doc string, which is a form of documentation. I am new to Python, so perhaps people just write really good doc strings and don’t comment their code. Or perhaps, because python is supposed to be so easy and pseudo-code-like, there’s no need for comment-type documentation. I have been raised in a C/Java world where a program without comments is evil!

The author’s style is a kind of learn as you go type of thing instead of spending a whole chapter on an int or float or whatever. He presents a snippet of code at the beginning of the chapter and then “disects it line by line”. Both strategies have their plusses and minuses. So far, I have found Python to be a very interesting language. The Holy War of indentation style which plagues C, C++, and Java is gone in Python. You MUST indent correctly because indentation marks off blocks of code, not curly braces! This will be interesting for me. On the one hand, it makes Emacs very easy to use because it follows the indentation style every time I hit enter. With C and Java, it never wanted to automatically keep indenting for an if statement inside an if statement. (I’m sure there’s a way to change it as Emacs is highly customizable) However, I’ll have to train myself to look for the end of an indentation instead of curly braces to signify the end of a code block. I’m pretty excited because his programs are more than just toy programs, they’re a bit useful. I was skipping ahead a little (to see if he covered commenting when doing a more advanced program) and was delighted to see a program whose purpose was to sift through idv2 tags of MP3s! I can already think of a few uses for that! Exciting indeed!

Author: Eric Mesa

To find out a little more about me, see About Me