<commit_before># the problem

What directory should your app use for storing user data? If running on Mac OS X, you
should use:

    ~/Library/Application Support/<AppName>

If on Windows (at least English Win XP) that should be:

    C:\Documents and Settings\<User>\Application Data\Local Settings\<AppAuthor>\<AppName>

or possibly:

    C:\Documents and Settings\<User>\Application Data\<AppAuthor>\<AppName>

for [roaming profiles](http://bit.ly/9yl3b6) but that is another story.

On Linux (and other Unices) the dir is typically:

    ~/.<appname>     # note AppName was lowercased


# `appdirs` to the rescue

This kind of thing is what the `appdirs` module is for. `appdirs`:

- will tell you an appropriate user data dir (`user_data_dir`)
- will tell you an appropriate user caches dir (`user_caches_dir`)
- will tell you an appropriate site data dir (`site_data_dir`)
- is a single module so other Python packages can include their own private copy
- is slightly opinionated on the directory names used (especially on Linux/Unix
  where standards for these dirs don't really exist, AFAIK)

# some example output




# typical usage


<commit_msg>readme examples<commit_after># the problem

What directory should your app use for storing user data? If running on Mac OS X, you
should use:

    ~/Library/Application Support/<AppName>

If on Windows (at least English Win XP) that should be:

    C:\Documents and Settings\<User>\Application Data\Local Settings\<AppAuthor>\<AppName>

or possibly:

    C:\Documents and Settings\<User>\Application Data\<AppAuthor>\<AppName>

for [roaming profiles](http://bit.ly/9yl3b6) but that is another story.

On Linux (and other Unices) the dir is typically:

    ~/.<appname>     # note AppName was lowercased


# `appdirs` to the rescue

This kind of thing is what the `appdirs` module is for. `appdirs`:

- will tell you an appropriate user data dir (`user_data_dir`)
- will tell you an appropriate user caches dir (`user_caches_dir`)
- will tell you an appropriate site data dir (`site_data_dir`)
- is a single module so other Python packages can include their own private copy
- is slightly opinionated on the directory names used (especially on Linux/Unix
  where standards for these dirs don't really exist, AFAIK)

# some example output

On Mac OS X:

    >>> from appdirs import *
    >>> appname = "SuperApp"
    >>> appauthor = "Acme"
    >>> user_data_dir(appname, appauthor)
    '/Users/trentm/Library/Application Support/SuperApp'
    >>> site_data_dir(appname, appauthor)
    '/Library/Application Support/SuperApp'
    >>> user_cache_dir(appname, appauthor)
    '/Users/trentm/Library/Caches/SuperApp'

On Windows 7:

    >>> from appdirs import *
    >>> appname = "SuperApp"
    >>> appauthor = "Acme"
    >>> user_data_dir(appname, appauthor)
    'C:\\Users\\trentm\\AppData\\Local\\Acme\\SuperApp'
    >>> user_data_dir(appname, appauthor, roaming=True)
    'C:\\Users\\trentm\\AppData\\Roaming\\Acme\\SuperApp'
    >>> user_cache_dir(appname, appauthor)
    'C:\\Users\\trentm\\AppData\\Local\\Acme\\SuperApp'
    # Suggest at least "Caches" is appended to this to separate from
    # `user_data_dir`.
    >>> from os.path import join
    >>> join(user_cache_dir(appname, appauthor), "Caches")
    'C:\\Users\\trentm\\AppData\\Local\\Acme\\SuperApp\\Caches'

On Linux:

    >>> from appdirs import *
    >>> appname = "SuperApp"
    >>> appauthor = "Acme"
    >>> user_data_dir(appname, appauthor)
    '/home/trentm/.superapp
    >>> site_data_dir(appname, appauthor)
    '/etc/superapp'
    >>> user_cache_dir(appname, appauthor)
    '/home/trentm/.superapp/caches'


# typical usage



{'fraction_non_alphanumeric': 0.11320754716981132, 'fraction_numerical': 0.0019141372709871479, 'mean_word_length': 3.6957637997432604, 'pattern_counts': {'":': 0, '<': 19, '<?xml version=': 0, '>': 79, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4343107', 'n_tokens_mistral': 1176, 'n_tokens_neox': 1123, 'n_words': 381}