Woah, I loved how expository your code was. I am also a python programmer but am not too familiar with this module. Thanks for the tutorial. A question though. Why is the dump
function there when a suitable alternative would be to commit the dictionary to a file simply using such code for example
x = open(filename, 'w+')
x. write(fav_cryptos)
x. close
Wouldn't this append the file to the document or is it for a more peculiar purpose?
Hi, and thx! ;-)
I've discussed 2 modules,
pickle
andshelve
(they're two different modules, whereshelve
is built on top ofpickle
). The key take-away of this episode is to explain thatdumping
viapickling
is a way to "serialize" a Python object (for example a dictionary or a list), which is kept in RAM and only works "inside the program), and is then "pickled" to save in a file in a binary mode, where the pickle contains the full instructions to un-pickle, ergo, to read it back, by another or the same program at another time, after the program was closed, and to put it back in RAM.Simple use case? When you're playing a game and you're saving your progress on level 14 before you to to sleep. Saving the "game state" == pickling ;-)
Ooh wow
That's elucidiated things
I fully get the application now
Its like saving a data state and all the changes with a single module. That's awesome
Thanks
Hey @yalzeee Here's a tip for your valuable feedback! @Utopian-io loves and incentivises informative comments.
Contributing on Utopian
Learn how to contribute on our website.
Want to chat? Join us on Discord https://discord.gg/h52nFrV.
Vote for Utopian Witness!