will be your very own module that you can import whenever you want to use the variable stored in it for exampleenter the following into the interactive shellimport pprint cats [{'name''zophie''desc''chubby'}{'name''pooka''desc''fluffy'}pprint pformat(cats"[{'desc''chubby''name''zophie'}{'desc''fluffy''name''pooka'}]fileobj open('mycats py'' 'fileobj write('cats pprint pformat(cats'\ ' fileobj close(herewe import pprint to let us use pprint pformat(we have list of dictionariesstored in variable cats to keep the list in cats available even after we close the shellwe use pprint pformat(to return it as string once we have the data in cats as stringit' easy to write the string to filewhich we'll call mycats py the modules that an import statement imports are themselves just python scripts when the string from pprint pformat(is saved to py filethe file is module that can be imported just like any other and since python scripts are themselves just text files with the py file extensionyour python programs can even generate other python programs you can then import these files into scripts import mycats mycats cats [{'name''zophie''desc''chubby'}{'name''pooka''desc''fluffy'}mycats cats[ {'name''zophie''desc''chubby'mycats cats[ ]['name''zophiethe benefit of creating py file (as opposed to saving variables with the shelve moduleis that because it is text filethe contents of the file can be read and modified by anyone with simple text editor for most applicationshoweversaving data using the shelve module is the preferred way to save variables to file only basic data types such as integersfloatsstringslistsand dictionaries can be written to file as simple text file objectsfor examplecannot be encoded as text projectgenerating random quiz files say you're geography teacher with students in your class and you want to give pop quiz on us state capitals alasyour class has few bad eggs in itand you can' trust the students not to cheat you' like to randomize the reading and writing files