Python Learning Journal (Part II - Preparing for Mechanize)

To get familiar with Python syntax, I'll start with a play-around with web crawler scripts. I'll be using Mechanize, a supposedly stateful programmatic web browsing module. For introduction, I'll try to write a script to list out recent torrents from And later I'll proceed with a script to retrieve and then summarize flight tickets price from Input parameters would be date range, origin city, and destination city. Then the script shall print out a table consists of date, time, and price. And then it will list out additional fees and taxes that will be applied upon payment.

Mechanize Installation

There is one thing I like about python, it's that everything comes with a general installation script:
python install

Unlike Java, you need to mess around with path, classpath, and jar files.
So, to install Mechanize, it's as simple as downloading the archive, and then unpack followed by running the command with sudo.


For editor, I'm using Eclipse with PyDev plugin.
To install this Plugin, simply go to Help | Install New Software, and then setup new site:
Later, just go to Preference and setup this section: "Interpreter - Python".


For me, code convention is very important. And thus, here is the general convention of Python - PEP 8.
Let me summarize here things that are new to me:
  • For indentation use 4 spaces, not tab
  • No space before and after = to indicate a keyword argument or default parameter
  • For package and module name use lowercase no underscore
  • For class name use CamelCase
  • For internal class name use CamelCase and one leading underscore
  • Exception name should have the suffix "Error"
  • Function/method/instance variables names use underscored lowercase
  • Non-public method/instance variables names use underscored lowercase and one leading underscore
Below are some basic readings to do:

0 comments: (+add yours?)