简体   繁体   中英

How to change the name of dictionary in the file when using klepto.archives.file_archive?

After running the following code, I found that the name of the dictionary in file memo.py is memo . I want to change the name of the dictionary in that file. Do anyone know how to do it?

>>> init = {'y': 2, 'x': 1, 'z': 3}
>>> import klepto
>>> cache = klepto.archives.file_archive('memo', init, serialized=False)
>>> cache        
{'y': 2, 'x': 1, 'z': 3}
>>>
>>> # dump dictionary to the file 'memo.py'
>>> cache.dump() 
>>> 
>>> # import from 'memo.py'
>>> from memo import memo
>>> print memo
{'y': 2, 'x': 1, 'z': 3}
>>> from memo import memo
>>> print memo
{'y': 2, 'x': 1, 'z': 3}

I'm the klepto author. I don't believe it's possible, currently. However, if you do want it as a feature, then feel free to request it (on klepto 's GitHub) as an enhancement.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM