[Pythonmac-SIG] Re: Where to put data

Russell E. Owen rowen at cesmail.net
Tue Dec 21 21:17:37 CET 2004


In article <3479352C-5364-11D9-9C37-000D933C27EA at conncoll.edu>,
 Charles Hartman <charles.hartman at conncoll.edu> wrote:

>...a file of data...which will grow and change as the app is used; when 
the 
> app terminates the data ought to be saved  with it for next time. In 
> this case I don't want users fiddling with it apart from the app.
> 
> What is the right way to do this? (What's the easy way?) Is there a 
> simple method that will work for both Mac and Windows (and Linux)?

I suggest you download the RO package 
<http://www.astro.washington.edu/rowen/ROPython.html> and look at 
RO.OS.getPrefsDir:
    Return the user's preferences directory, if found, else None.
    
    For MacOS X this is often:
        ~/Library/Preferences (with ~ expanded)
    For Mac Classic this is often:
        System Folder:Preferences
    For unix this is the user's home directory.
    For Windows this is often:
        Windows\Application Support

and RO.OS.getAppSuppDirs:
    Return one or more application support paths
    (starting with user and going to more widely shared),
    or [] if none found.
    
    For MacOS X this may be:
        [~/Library/Application Support, /Library/Application Support]
    For Mac Classic this is probably [] but I'm not sure.
    for unix and Windows this is [getPrefsDir()]

That may help you locate the file, but does not answer how to keep users 
from fiddling around with it. It'll be a bit buried on Mac and Unix, but 
all-too-visible on unix unless you pre-pend a "." to the name.

-- Russell



More information about the Pythonmac-SIG mailing list