[Tutor] Changes to dbm module/file format

Alan Gauld alan.gauld at btinternet.com
Fri Oct 16 03:38:25 EDT 2015


On 16/10/15 01:21, Steven D'Aprano wrote:

> Python 2.5, under Linux:
>
>      dbm.open('foo', 'w')
>
> creates two files:
>
>      foo.dir  foo.pag
>
>
> Likewise for Python 2.7.
>

Thanks Steven.

> In Python 3.3 and 3.4, you need to pass the 'c' or 'n' flag, not 'w',
> and only a single file is created: "foo".

I always used 'c' to create a new 'file' even on 2.x...

Can anyone confirm those results on Windows for 3.x please?

PS.
Although Steven only got 2 files under 2.7 a third(.bak) would be 
created if he modified the contents. Hence my comment about 3
files being produced per database.

-- 
Alan G
Author of the Learn to Program web site
http://www.alan-g.me.uk/
http://www.amazon.com/author/alan_gauld
Follow my photo-blog on Flickr at:
http://www.flickr.com/photos/alangauldphotos




More information about the Tutor mailing list