problems with shelve

N

Nemesis

I used shelve to build a dictionary with 100 elements. I saved the file
(on Linux) and reaopened it on Windows, but I noticed a strange
behaviour.
Let's call dic the shelve opened, the command "len(dic)" returned 89 but
"len(dic.keys())" "len(dic.values())" "len(dic.items())" returned 100.

I dumped the shelve on a real dictionary and then I dumped this
dictionary in to another shelve. len() on this new shelve returned 93.

Alex Martelli told me that probably I should open the file in binary
mode on Windows ... but I don't know how.

This is the syntax of shelve.open:

open( filename[,flag='c'[,protocol=None[,writeback=False[,binary=None]]]])

binary is deprecated, and however I tried it but nothing changed.
flag refers to the opening for reading/writing ...
protocol is the protocol used by cPickle

How can manage on different platforms the same shelve?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,743
Messages
2,569,478
Members
44,899
Latest member
RodneyMcAu

Latest Threads

Top