Path: csiph.com!x330-a1.tempe.blueboxinc.net!usenet.pasdenom.info!news.albasani.net!newsfeed.x-privat.org!news.glorb.com!npeer02.iad.highwinds-media.com!news.highwinds-media.com!feed-me.highwinds-media.com!spln!extra.newsguy.com!newsp.newsguy.com!not-for-mail From: Chris Torek Newsgroups: comp.lang.python Subject: Re: Unshelving the data? Date: 2 Jun 2011 03:24:27 GMT Organization: None of the Above Lines: 28 Message-ID: References: <4433955b-7f54-400a-af08-1f58a75e734c@j31g2000yqe.googlegroups.com> NNTP-Posting-Host: p6de0f8403017f52d0d8f9433162c1becca3835248f9e60ba.newsdawg.com X-Newsreader: trn 4.0-test76 (Apr 2, 2001) Originator: torek@elf.torek.net (Chris Torek) Xref: x330-a1.tempe.blueboxinc.net comp.lang.python:6835 In article <4433955b-7f54-400a-af08-1f58a75e734c@j31g2000yqe.googlegroups.com> Uncle Ben 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