The shelve module will try to use one of three underlying database implementations: gdbm, ndbm or dumbdbm (see here). When neither gdbm or ndbm is found it falls back to dumbdbm. With dumbdbm implementation, it seems that opening in with the r flag (for read only) seems to have no effect on preventing writes. See this for example. The fix is to use gdbm or ndbm. On MacOS cursory testing shows that ndbm gets used by default (even with Anaconda) whereas on Linux:
You need to do: sudo apt-get install python3-gdbm to install the module and then
Manually link the library. See this answer for details.
The
shelve
module will try to use one of three underlying database implementations:gdbm
,ndbm
ordumbdbm
(see here). When neithergdbm
orndbm
is found it falls back todumbdbm
. Withdumbdbm
implementation, it seems that opening in with ther
flag (for read only) seems to have no effect on preventing writes. See this for example. The fix is to usegdbm
orndbm
. On MacOS cursory testing shows thatndbm
gets used by default (even with Anaconda) whereas on Linux:sudo apt-get install python3-gdbm
to install the module and then