[Tutor] Still searching in html files

Stefan Behnel stefan_ml at behnel.de
Thu Jan 21 12:56:54 CET 2010


Paul Melvin, 21.01.2010 10:03:
> I am still looking for information in these files and have a sort of
> 'clunky' solution that I would like feedback on please.
> 
> The code is at http://python.codepad.org/S1ul2bh7 and the bit I would like
> some advice on is how to get the sorted data and where to put it.

Looks like you already didn't take the good advice to use an HTML parser.


> I want to expand the program to give some output which the user can interact
> with, e.g. 'which of this information do you want me to get?' and the user
> would choose.  Does anyone have any tips on this? Can I just use things like
> raw_input and lists?

I'd advise against that, although this obviously depends on the type of
users you expect. Likely, you'd rather want a) a command line interface so
that you can also use it from other scripts (look at the optparse module
for that), and b) a suitable module API so that you can use the code from
other Python modules. Try to make your code reusable by splitting it into
separate functions and classes, and move it out of the top module level.

Stefan



More information about the Tutor mailing list