with shelvesthe files created by an underlying dbm system used to store your persistent objects are not necessarily compatible with all possible dbm implementations or pythons for instancea file generated by gdbm on linuxor by the bsddb library on windowsmay not be readable by python with other dbm modules installed this is really the same portability issue we discussed for dbm files earlier as you'll recallwhen dbm file (or by proxya shelveis createdthe dbm module tries to import all possible dbm system modules in predefined order and uses the first that it finds when dmb later opens an existing fileit attempts to determine which dbm system created it by inspecting the files(sbecause the bsddb system is tried first at file creation time and is available on both windows and many unix-like systemsyour dbm file is portable as long as your pythons support bsd on both platforms this is also true if all platforms you'll use fall back on python' own dbm dumb implementation if the system used to create dbm file is not available on the underlying platformthoughthe dbm file cannot be used if dbm file portability is concernmake sure that all the pythons that will read your data use compatible dbm modules if that is not an optionuse the pickle module directly and flat files for storage (thereby bypassing both shelve and dbm)or use the oodb systems we'll meet later in this such systems may also offer more complete answer to transaction processingwith calls to commit changesand automatic rollback to prior commit points on errors pickled class constraints in addition to these shelve constraintsstoring class instances in shelve adds set of additional rules you need to be aware of reallythese are imposed by the pickle modulenot by shelveso be sure to follow these if you store class instance objects with pickle directly tooclasses must be importable as we've seenthe python pickler stores instance attributes only when pickling an instance objectand it reimports the class later to re-create the instance because of thatthe classes of stored objects must be importable when objects are unpickled--they must be coded unnested at the top level of module file that is accessible on the module import search path at load time ( named in python path or in pth fileor the current working directory or that of the top-level scriptfurtherthe class usually must be associated with real imported module when instances are picklednot with top-level script (with the module name __main__)unless they will only ever be used in the top-level script you also need to be careful about moving class modules after instances are stored when an instance is unpickledpython must find its class' module on the module search using the original module name (including any package path prefixesand fetch the class shelve files