How to write temporary data to file?
Thomas Ploch
Thomas.Ploch at gmx.net
Tue Jan 9 10:02:51 EST 2007
Thomas Ploch schrieb:
> Laszlo Nagy schrieb:
>> Thomas Ploch írta:
>>> Hi folks,
>>>
>>> I have a data structure that looks like this:
>>>
>>> d = {
>>> 'url1': {
>>> 'emails': ['a', 'b', 'c',...],
>>> 'matches': ['d', 'e', 'f',...]
>>> },
>>> 'url2': {...
>>> }
>>>
>>> This dictionary will get _very_ big, so I want to write it somehow to a
>>> file after it has grown to a certain size.
>>>
>>> How would I achieve that?
>>>
>> How about dbm/gdbm? Since urls are strings, you can store this dict in a
>> database instance and actually use it from your program as it were a dict?
>>
>> Laszlo
>>
>
> Well, but how do I save the nested dict values? I don't want to eval
> them, so this is no option for me.
>
> Thomas
I just saw shelve is the module to go for.
Thomas
More information about the Python-list
mailing list