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 -- http://mail.python.org/mailman/listinfo/python-list