difference b/t dictionary{} and anydbm - they seem the same

davidj411 davidj411 at gmail.com
Tue Mar 11 09:49:49 EDT 2008


anydbm and dictionary{} seem like they both have a single key and key
value.
Can't you put more information into a DBM file or link tables? I just
don't see the benefit except for the persistent storage.

d= dbm.open('c:\\temp\\mydb.dat','n')

It has the following interface (key and data are strings):

        d[key] = data   # store data at key (may override data at
                        # existing key)
        data = d[key]   # retrieve data at key (raise KeyError if no
                        # such key)
        del d[key]      # delete data stored at key (raises KeyError
                        # if no such key)
        flag = key in d   # true if the key exists
        list = d.keys() # return a list of all existing keys (slow!)



More information about the Python-list mailing list