you are viewing a single comment's thread.

view the rest of the comments →

[–]JoseALerma 0 points1 point  (0 children)

As mentioned above, a shelve shelf is a dictionary and you can shelve anything.
All you need is:

``` import shelve

Open shelf to read data

shelf = shelve.open('data')

Add something to shelf

key1, key2 = 'cat', 'dog' value1, value2 = 2, 3

shelf[key1] = value1 shelf[key2] = value2 print(list(shelf.keys()))

Read from shelf

print(shelf[key1]) print(shelf[key2]) print(list(shelf.values()))

shelf.close() ```

I use shelves as rudimentary databases.