list comprehension help

Marc 'BlackJack' Rintsch bj_666 at gmx.net
Sun Mar 18 12:44:23 EDT 2007


In <mailman.5248.1174235057.32031.python-list at python.org>, Daniel Nogradi
wrote:

>> f = open('file.txt','r')
>> for line in f:
>>         db[line.split(' ')[0]] = line.split(' ')[-1]
>>         db.sync()
> 
> What is db here? Looks like a dictionary but that doesn't have a sync method.

Shelves (`shelve` module) have this API.  And syncing forces the changes
to be written to disks, so all caching and buffering of the operating
system is prevented.  So this may slow down the program considerably.

Ciao,
	Marc 'BlackJack' Rintsch



More information about the Python-list mailing list