filename used by shelve
Fredrik Lundh
fredrik at pythonware.com
Sun Apr 24 14:38:04 EDT 2005
"Nemesis" <nemesis at nowhere.invalid> wrote:
> So the real filename may be different from the argument passed to
> "open". I have this problem, I want to delete (in some circustances) the
> file created by shelve.open, how can I know which is the name of this
> file (or files) ?
if you put the shelve in a subdirectory, and nuke the entire directory when
done, you don't have to know the names.
dbfile = "mydatabase"
if not os.path.isdir(dbfile):
os.makedirs(dbfile)
db = shelve.open(os.path.join(dbfile, "data"), ...)
...
db.close()
del db
...
shutil.rmtree(dbfile)
</F>
More information about the Python-list
mailing list