[Tutor] shelves behaving badly

Luke Jordan luke.jordan at gmail.com
Thu Aug 2 20:51:24 CEST 2007


i think that some form of that is going on. actually there is only one
shelve; that's the confusing part, there are dictionaries in that shelve
though. i think it has to do with running things in IDLE and losing track of
what versions of shelves and modules are active in what shell, etc etc,
because i ran it again and it worked fine. it must be something to do with i
screwed something up in testing and forgot about it. i haven't found a
definitive answer to why it behaves this way, but so far the solution has
been to confine myself to one shell and to close out and reopen everytime
edits/reruns are made. thanks for the tip on checking things with os.

On 8/2/07, Kent Johnson <kent37 at tds.net> wrote:
>
> Luke Jordan wrote:
> > i've implemented a database as a shelve of record class instances. some
> > of the fields in each record are dictionaries.
> >
> > i needed to parse info from 3 different reports into the dictionary
> > fields in each record instance. i wrote the code to do this and tinkered
> > it to fit the different reports (i.e. information being in different
> > columns, etc.). for 2 of the reports, it runs fine. the required info
> > turns up in the shelve after i run the code, and i can exit and reenter
> > python, open the shelve, and it's all still there, where it should be.
> > i've quadruple checked the code for the third report, and it looks like
> > it should work. in fact it runs, and reports back that it did everything
> > i told it to do; this includes checking results as they occur at
> > runtime. however, when i reopen the shelve, none of that data is there.
> > writeback is set to True, and I didn't forget to close the shelve at the
> > end of my code.
> >
> > Now, if I open the shelve in the same shell as the script ran in, right
> > after I run it, I get the updated shelve. but any other method of
> > opening the shelve results in the shelve missing the data from the third
> > report.
> >
> > Any ideas what's going on here?
>
> It's pretty hard to say without seeing the code. I wonder if you are
> saving the third shelve in a different location than you think you are,
> and opening an old one in the other programs? Maybe check the full path
> of the file you save (use os.path.abspath()) and check the modified date
> of the one you open.
>
> Kent
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.python.org/pipermail/tutor/attachments/20070802/fa79e6a6/attachment.html 


More information about the Tutor mailing list