Search code examples
pythoncross-platform

Is there a standard way to get the user config directory in python


I can get the home with os.path.expanduser("~") but is there a standard way to get the config directory? Like ~/.config in most unices, or the value of $XDG_CONFIG_HOME in (recent?) Linux and C:\Users\<user>\AppData\Local\Roaming in Windows), etc


Solution

  • You can take advantage of python third party library appdirs platformdirs which does all the heavy lifting for you across multiple platforms ( Windows, Linux & Mac )