Unshelving the data?

Chris Torek nospam at torek.net
Wed Jun 1 23:24:27 EDT 2011


In article <4433955b-7f54-400a-af08-1f58a75e734c at j31g2000yqe.googlegroups.com>
Uncle Ben  <bgreen at nycap.rr.com> wrote:
>Shelving is a wonderfully simple way to get keyed access to a store of
>items. I'd like to maintain this cache though.
>
>Is there any way to remove a shelved key once it is hashed into the
>system?

$ pydoc shelve
...
    To summarize the interface (key is a string, data is an arbitrary
    object):
    ...
            d[key] = data   # store data at key (overwrites old data if
                            # using an existing key)
            data = d[key]   # retrieve a COPY of the data at key (raise
                            # KeyError if no such key) -- NOTE that this
                            # access returns a *copy* of the entry!
            del d[key]      # delete data stored at key (raises KeyError
                            # if no such key)
    ...

Seems pretty straightforward. :-)  Are you having some sort
of problem with "del"?
-- 
In-Real-Life: Chris Torek, Wind River Systems
Salt Lake City, UT, USA (40°39.22'N, 111°50.29'W)  +1 801 277 2603
email: gmail (figure it out)      http://web.torek.net/torek/index.html



More information about the Python-list mailing list