1

I'm working on a really simple python package for our internal use, and want to package it as a .egg file, and when it's installed/used I want it to access a text file that is placed in an appropriate place on the computer.

So where is the best place to put application data in python? (that is meant to be edited by users) How do I get my python package to automatically install a default file there?

note: I know about the Windows application data directory, but would like to avoid it, as it's nonportable and kind of cumbersome both for users to access and for my application to access.

Community
  • 1
  • 1
Jason S
  • 184,598
  • 164
  • 608
  • 970
  • well, probably windows, but tying it to a specific OS seems clunky. it's not somewhere in the site-packages dir? – Jason S May 17 '10 at 20:43

2 Answers2

3

os.path.expanduser('~')

Ignacio Vazquez-Abrams
  • 776,304
  • 153
  • 1,341
  • 1,358
0

Each OS will have it's own directory where application data is expected to exist. There does not appear to be a method that provides this path in a platform-independent manner. You can write your own function to do this for you by checking os.name and then returning the appropriate value depending on the result.

Mike
  • 19,114
  • 12
  • 59
  • 91
unholysampler
  • 17,141
  • 7
  • 47
  • 64