Should I prefer an external database

Brian Elmegaard brian at rk-speed-rugby.dk
Tue Apr 22 04:11:45 EDT 2003


Hi,

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):
                self.title=title
                self.author=author
                self.session=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
instances? 
What about a class of classes? Could such be made and inherit from the
list class to support index and sort?

tia,
-- 
Brian (remove the sport for mail)
http://www.et.dtu.dk/staff/be




More information about the Python-list mailing list