If you have gimp installed via your Linux distro,
GIMP-Python is probably already included.
To make sure, look for a Filters->Python-Fu menu.
If you built your own GIMP and don't have the Python-fu, it may
be that you didn't have python-gtk2 or python-gtk2-dev installed
when you built it. Install them and re-run configure and
you should be able to rebuild gimp with Python support. (In Ubuntu, you should have Xtns -> Python Fu-- ed.)

GIMP-Python scripts live under your home directory, in
.gimp-2.6/plug-ins/. If you're using a different
GIMP version, like 2.4 or 2.7, change the name appropriately.
So edit a file there -- for example,
$HOME/.gimp-2.6/plug-ins/pytest -- and start with the
following headers: