Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #6835
| From | Chris Torek <nospam@torek.net> |
|---|---|
| Newsgroups | comp.lang.python |
| Subject | Re: Unshelving the data? |
| Date | 2011-06-02 03:24 +0000 |
| Organization | None of the Above |
| Message-ID | <is6vpb0hds@news3.newsguy.com> (permalink) |
| References | <4433955b-7f54-400a-af08-1f58a75e734c@j31g2000yqe.googlegroups.com> |
In article <4433955b-7f54-400a-af08-1f58a75e734c@j31g2000yqe.googlegroups.com>
Uncle Ben <bgreen@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
Back to comp.lang.python | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
Unshelving the data? Uncle Ben <bgreen@nycap.rr.com> - 2011-06-01 19:49 -0700
Re: Unshelving the data? Chris Torek <nospam@torek.net> - 2011-06-02 03:24 +0000
Re: Unshelving the data? Ben Finney <ben+python@benfinney.id.au> - 2011-06-02 13:25 +1000
Re: Unshelving the data? Adam Tauno Williams <awilliam@whitemice.org> - 2011-06-02 06:46 -0400
Re: Unshelving the data? Uncle Ben <bgreen@nycap.rr.com> - 2011-06-02 06:17 -0700
csiph-web