filename used by shelve

Nemesis nemesis at nowhere.invalid
Mon Apr 25 04:55:01 EDT 2005


Mentre io pensavo ad una intro simpatica "Fredrik Lundh" scriveva:

>> 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"), ...)
>     shutil.rmtree(dbfile)

Hmm, this is a good idea. Thanks.

Anyway I think that shelve should provide a method which returns the
files used by the backend database, and the argument "filename" can
confuse users, it should be named "dbname".

-- 
Are crop circles the work of a cereal killer?
 
 |\ |       |HomePage   : http://nem01.altervista.org
 | \|emesis |XPN (my nr): http://xpn.altervista.org




More information about the Python-list mailing list