# Saving user preferences

Because Python applications can be distributed in several ways, including within ZIP files, it is usually not feasible to save user preferences, high score lists, and so on within the application directory (or worse, the working directory).

The pyglet.resource.get_settings_path function returns a directory suitable for writing arbitrary user-centric data. The directory used follows the operating system's convention:

- `~/.ApplicationName/` on Linux
- `$HOME\Application Settings\ApplicationName` on Windows
- `~/Library/Application Support/ApplicationName` on Mac OS X

The returned directory name is not guaranteed to exist -- it is the application's responsibility to create it. The following example opens a high score list file for a game called "SuperGame" into the settings directory:

    import os

    dir = pyglet.resource.get_settings_path('SuperGame')
    if not os.path.exists(dir):
        os.makedirs(dir)
    filename = os.path.join(dir, 'highscores.txt')
    file = open(filename, 'wt')