First Python, then the world!

I don't know Python, but I'm going to try to learn.

April 28, 2009 at 10:04pm

Day 2: Preparation.

One of the first things anybody has to do when working with a new programming language is make sure their text editor is fully aware of the conventions used in that language. My .vimrc has plenty of settings for Ruby, but none for Python.

The fact that a document like PEP 8 exists to set people straight on the preferred way to format Python code blows my mind. Coming from a community where everybody has their own library for accessing Twitter or formatting Markdown, having everyone agree (at least officially) on the way to even format code blows me away. And even if this is just the letter of the law, it is certainly followed: the vim plugin indent/python.vim states its goal as

to match more closely what is suggested in PEP 8.

This is wonderful! I’ve also used, for reference, Henry Precheur’s Indenting Python with VIM post to ensure consistency on indenting comments and the like. This may seem like kid-stuff to someone who has been using the language for an extended period of time, but being comfortable in my editor and knowing it’s doing the right thing, even if I don’t fully understand why, is extremely important.

On top of this, I needed to find a counterpart to irb. I knew Python came with a built-in interactive interpreter, but it doesn’t support history, color, tab-completion… all the things I’ve come to expect from an extended and improved irb. I considered using IDLE, but I much preferred the idea of something that could run in native terminals, so I could keep it in a screen session, and so on. Then I found ipython. And I fell in love.

ipython showing off what it does best: everything.

I feel like this development environment is unrolling the red carpet for me. And it’s awesome.

12:33am

Day 1: Realization.

It’s finally time I sat down and started learning something that wasn’t Ruby. Something with a reasonably respectable community. Something with an enormous base of technical support. Something with an effective benevolent dictator for life. Something like Python.

I’ve used Python once or twice before. I wrote part of a horrible engine in PyGame, which is now being written in RubyGame. I’ve fiddled with AsciiDoc, which is written in Python. I got a D in a Data Structures class because implementations had to be in Python. So I haven’t had the best history with it.

But there are things I like the idea of. Whitespace instead of curly braces. Documentation as first class citizens. A ubiquitous testing culture and, similarly, unittest. Sphinx. The use of ReStructured Text.

So now I want to set out to learn Python, and learn the tools and environments and culture of the language along the way. It’s probably going to be a long, arduous journey, with a lot of heartache along the way, but what good adventure isn’t?

I’m a web developer by trade. I’ve learned ASP Classic, ASP.NET, and Ruby on Rails. There’s a lot of good buzz about Django right now, and I think I’d really be missing out if I didn’t see what the fuss was all about. My plan of action is thus:

  • Read the ReStructured Text Primer and get used to its conventions, versus Markdown and AsciiDoc.
  • Start the Django 1.0 Tutorial. See if I like the way it moves.
  • Continue reading the Python tutorial. The basics are really fast to skim through if you’ve already used similar programming languages. Right now I’m up to ยง4.7.3.

If I can somehow manage to juggle job interviews, school, senior design, and moving between apartments, along with the things I want to accomplish with Python, I’ll be a very happy super-human. Realistically I know it may be a while—a week or two—before I can continue on my way, but I’m optimistic. This feels right.

Onward, then!