Skip to content

Learning Python… and making cool tools with it!

by Nat on September 9th, 2010

As a part of a larger learning project that I’ve been involved in, in which I installed Ubuntu Linux onto my home PC, and have been working on mastering several tools and techniques using it, I’m now working on learning the Python programming language in order to build quick, useful tools.

As a programmer who likes coding both as a part of my job and in my spare time, I have a lot of experience writing code, and have written at least basic programs in a few different languages: Java, Lisp, C#, PHP, and more than anything else, C/C++ for a lot of different platforms, including game consoles. For people who don’t know a lot about programming languages and what’s good for what, you may be surprised that there’s no language where you can do everything you’d possibly want to do in the easiest way, although a lot of language designers have tried to make this a goal for language design. I’ve ended up doing some very different things in different languages. Some examples:

  • In college, I wrote a Java-based networked multiplayer version of the fantastic pattern-matching card game of Set. (I highly recommend the game if you’ve never tried it before). I designed and wrote the program all in one night, after several weeks of procrastination. The code was terribly messy but worked relatively well. Using Java helped me develop quickly, as its network and graphical interfaces are a lot more simply designed than other languages. Getting two computers to communicate with each other took about a half an hour. Thanks, Java!
  • Again in college, I once used Lisp to write a routine that went through a big, linked data structure representing several major cities of France, linked together by roads, and used A* pathfinding to find the shortest path between any two cities. Lisp makes this easier than it might be in other languages, because it deals with linked lists of items in very manageable and intuitive ways.
  • As a personal project, I’ve created websites that use PHP to manage a database of users and posts, letting users create webpages, comments, etc. from within other webpages (as opposed to having to use text editors or web development applications to build websites, which is SO 1990′s!). I also administrate a wiki called Lexipedia, which runs on the same PHP framework as Wikipedia and is pretty easy to modify and customize because I already know PHP. Since PHP is so close to the HTML level, it makes generating a webpage with code very easy. (It’s not the only language which does this, but it’s the one that I know best.)

I’ve given the following examples to demonstrate for those of you who don’t write code regularly how different the applications for different languages can be. If you’re already a programmer, I’m just preaching to the choir, I’m sure.

I started learning Python a few weeks ago out of a desire to write handy little scripts to make using my computer more convenient, and if possible, more fun. Python is a really cool language because it’s extremely fast to write, and can accomplish some really cool stuff without too much work on the programmer’s part. Plus, it’s been immensely fun to learn. I know there are a lot of other scripting languages I could be using (Perl and Ruby come to mind, and I’ve dabbled in both), but for now I’m going with Python.

Right now I’m going through Google’s excellent series of beginning Python courses online, which can be found here. Nick Parlante is a really good instructor–I wish my company had the sort of high-level, technical, professional development classes that Google does for their employees!

So now, for concrete goals!

  • This might be cheating, but the first goal is one I’ve already accomplished: write a simple little quiz application, which I can use to quiz myself on stuff. If you have Python, you can grab the first draft of my code here, as well as a couple of simple, sample quizzes here and here. Also, I wrote a little bash script to pick a random question from a random quiz, and ask it to you (here). (Pretty fun to set this up as a cronjob, Unix/Linux people!)
  • Since the first one was cheating, I have some changes I’d like to make to improve my quiz script. First, make it so that it accepts multiple possible answers to each question (right now, there’s only one possible correct answer for each). Second, make it so that the delimiter for the quiz file format can be escaped.
  • Solve all of the Python exercises on Nick Parlante’s CodingBat code practice website. This shouldn’t be too tough and will give me good practice.

I’m not sure where I’m ultimately going with this; eventually there might be some grander project in the future here, or perhaps Python will just become another tool in my belt, and not a lot more. We’ll see where this takes me.

Anyway, I’m sure some of you are getting a little tired of technical projects for now, so the next project I’ll talk about will be related to home improvement! Look forward to it!

From → Python

2 Comments
  1. Ghalib permalink

    Hi Nat, have you seen http://www.pythonchallenge.com/ ?

    PS Saw link to your blog from the facebooks.

    • Nat permalink

      I have indeed! It’s a pretty fun site. I got to maybe level 6 or 7 before getting frustrated that a few of the puzzles were simply too unintuitive and somewhat unfair. I like complex puzzles when they’re cleverly constructed, but a few of their puzzles have red herrings and are poorly designed enough that I just got angry at them. I guess I can’t expect all obscure puzzles to be written like Mystery Hunt‘s puzzles.

      Anyway, I think solving puzzles (or accomplishing any sort of addictive task) with a language is a great way to learn it, so if you learn about any more sites like that, let me know!

Leave a Reply

Note: XHTML is allowed. Your email address will never be published.

Subscribe to this comment feed via RSS