linux python ideas

Edward C. Jones edcjones at
Wed Sep 18 18:23:16 EDT 2002

Rob Andrews wrote:
> I'll be giving a presentation on Python to my local LUG 
> ( in a few weeks, and would like to point out at least 
> a few things that would be of particular interest to linux users.
> The idea is not "how to program in Python", which would take more than 
> one quick presentation, but a one-off demonstration of ways in which 
> Python is particularly useful for such a group.
> Any suggestions would be appreciated, since my notes are pretty generic 
> so far.

I use Python instead of shell scripts for anything that is not 
completely trivial. Here is a small program for finding all the links in 
a page of html:

#! /usr/bin/end python

import sys

if len(sys.argv) != 2:
     raise Exception, 'program must have exactly one argument.'
infile = sys.argv[1]
page = open(infile, 'r').read()
lowerpage = page.lower()

start = 0
while 1:
	start = lowerpage.find('href="', start)
     if start == -1:
     start = start + len('href="')
	end = lowerpage.index('"', start)
     print page[start : end]

More information about the Python-list mailing list