Appropriate location for my application's cache on Windows
My application caches some data on disk. Because the cache may be large, it should not be stored on a network drive. It should persist between invocations of the application. I have a mechanism for the user to choose a location, but would like the default to be sensible and "the right thing" for the platform.
What is the appropriate location for such a cache? Is there an API for determining the appropriate location? How do I call it from Python?
Have a look here: http://en.wikipedia.org/wiki/Environment_variable#User_management_variables. Anything that's under the users directory is good. If its for all users, then it should be: %ALLUSERSPROFILE%. If its for a specific user, make sure the permissions are right.
Check out MSDN for more info about other Windows Versions. Environment variables can vary from systems to systems.
There are a number a places you can put your application files in Windows. This page shows a list (this enum is .Net specific but most of the special folders are standard on Windows in general). Basically you'll need to decide if you need a cache per user, only for the local machine, per application or shared, etc.
I don't have much experience with python so I cannot specifically help with how to get these paths, but I'm sure someone more knowledgeable here can.
The standard location for Windows application to store their (permanent) application data is referenced by the %APPDATA% (current user) or %ALLUSERSPROFILE% (all users) environment variables. You can access them using, e.g. (only rudimentary and not very elegant error checking!):
import os app_path = os.getenv("APPDATA") + "\\MyApplicationData" try: os.mkdir(app_path) except WindowsError: # already exists
Now you have your own directory for your app.