En Tue, 01 Apr 2008 00:48:35 -0300, <[EMAIL PROTECTED]> escribió: > We do have, but on Windows, file is not locked to multi-tasking, > shelve. But why don't we have types in there, or non-string > primitives in keys? > >>>> c= shelve.open( 'temp', 'c' ) >>>> c['0']= 'a' >>>> c.sync() >>>> del c >>>> c= shelve.open( 'temp', 'c' ) >>>> c['0'] > 'a' > >>>> c['0'].append( 0 ) >>>> c['0'] > []
The above session doesn't make sense unless it's somewhat related to "on Windows, file is not locked to multi-tasking," and another process has modified the database in-between. I don't think the problem is restricted to Windows only. There exist file locking mechanisms. > And why don't primitive mutations modify contents of disk? A > metaquestion. They do, if you pass writeback=True to the shelve constructor, but read the docs. shelve is a simple class; if it can't fulfill your needs, you may want to use a relational database (perhaps with an ORM like SQLObjects or SQLAlchemy) or an object database like ZODB or Durus. >>>> c['0']= type('None',(),{}) > Traceback (most recent call last): > pickle.PicklingError: Can't pickle <class '__main__.None'>: it's not > found as __main__.None Don't do that then. Or use the available pickle hooks to customize how such classes may be pickled. All persistence mechanisms have limitations. -- Gabriel Genellina -- http://mail.python.org/mailman/listinfo/python-list