Should I prefer an external database

Brian Elmegaard brian at
Tue Apr 22 10:11:45 CEST 2003


I am working on a script for organizing a program for a conference. I
started out using a connection to mySQL, but then I thought that it
would be easier to keep it within python. So I implemented a class:

class Paper:
        def __init__(title,author,session):
I then have a list to which each new paper instance is appended. I can
sort by any of the paper instances variables by using the
decorate-sort-undecorate method.

I now have it working, but I probably could do better, so:

Is this a more pythonic way to implement this?

To do a select I think I need to use for loops specifying the names of
the variables, i.e:

for paper in paperlist:
        if paper.session=='foo':
                print paper.title

Probably this might be done more elegantly, but how do I know which
variables (database columns) the instance has?

Would I be better of with a list of list than with a list of class
What about a class of classes? Could such be made and inherit from the
list class to support index and sort?

Brian (remove the sport for mail)

More information about the Python-list mailing list