On Feb 8, 5:29 pm, "Gabriel Genellina" <[EMAIL PROTECTED]> wrote: > En Fri, 08 Feb 2008 06:36:53 -0200, waltbrad <[EMAIL PROTECTED]> > escribió: > > > > > Working through the Mark Lutz book Programming Python 3rd Edition. > > > A couple of modules in the "Preview" chapter give me errors. Both on a > > shelve.open call: > > > Pretty simple code, (2nd example): > > =====code begin===== > > import shelve > > from people import Person, Manager > > > bob = Person('Bob Smith', 42, 30000, 'sweng') > > sue = Person('Sue Jones', 45, 40000, 'music') > > tom = Manager('Tom Doe', 50, 50000) > > > db = shelve.open('class-shelve') > > db['bob'] = bob > > db['sue'] = sue > > db['tom'] = tom > > db.close() > > ====code end==== > > shelve uses the anydbm module; anydbm tries to select the best database > module available, but apparently fails in your system. If you are just > learning Python, I don't think it's worth trying to fix it; instead, let's > force anydbm to use the fallback module dumbdbm (implemented in pure > python, slow, but bullet-proof, or at least arrow-proof :) ) > > Add these two lines at the start of your script: > > import dumbdbm, anydbm > anydbm._defaultmod = dumbdbm > > Remove the class-shelve.* files, if any, before running it. > > -- > Gabriel Genellina
Thanks to all for the help, but the only advice that worked was Gabriel's. I actually tried to look into the issue of fixing it, but I'm just too much of a novice. I put the two lines in a seperate module that I import to save typing. But as I gain experience I'd like to return to this issue and try to fix it. Can you give me advice on how to go about that? I'm working on a win98 system. I have python on a linux system, (Kubuntu) and winxp but it's more convenient right now for me to use the 98 laptop. -- http://mail.python.org/mailman/listinfo/python-list