I’d like to save my script’s data to disk to load next time the script runs. For simplicity, is it a good idea to use os.path.expanduser('~') and save a directory named “.myscript_data” there? It would only need to be read by the script, and to avoid clutter for the user, I’d like it to be hidden. Is it acceptable practice to place hidden “.files” on the users computer?
I’d like to save my script’s data to disk to load next time the
Share
On Windows, use a subfolder of
os.environ['APPDATA']; on Linux, a dot-folder under$HOMEis typical.You can also consider putting your files in a subdirectory of
~/.config*, which is a sort of emerging standard for configuration file placement. See also the XDG basefiles spec.Not entirely related, but interesting: origin of dotfiles
*(edit) More accurately,
os.environ.get('XDG_CONFIG_HOME', os.path.expanduser('~/.config'))as per the XDG spec.