Here is a nice tutorial @ raspberrypi.org on how to control a DC motor using Python.
In this guide, you’ll be controlling two motors from your Raspberry Pi using Python on the desktop. First, it’s best just to learn how to control the motor. Then, once you have it working, you could easily use your code to drive a Raspberry Pi-powered robot by detaching the monitor, mouse, and keyboard and building a robot around a chassis.
Control a stepper motor using Raspberry Pi – [Link]