[Tutor] Config file directory (was: File like object for Windows registry)

K.Weinert at gmx.net K.Weinert at gmx.net
Fri Aug 4 21:05:19 CEST 2006


Hello again!

Thanks a lot for the helpful hints! I was not aware that expanduser does also work on windows since I am on WinMe... 

My current approach is this:

import platform, os.path

def _detect_filepath():
  op_sys= platform.system()
  op_rel= platform.release()
  if op_sys=="Windows":
    if op_rel in ["XP"]:
      return os.path.expanduser("~")
    else:
      return os.path.dirname(__file__) # store in package directory
  elif op_sys=="Linux":
    return os.path.expanduser("~")
  else:
    raise "Unsupported operating system."

What do you think? If someone with a win2000 system could tell me the return value of platform.release(), that would be nice.

Kind regards,
Karsten.

----- Original Message -----
Hello!

My app should run on debian and windows platforms. For storing the configuration data, I use the ConfigParser module.

What I find difficult is to determine a place for my configuration file. On debian, it is simply

os.path.join(os.path.expanduser("~")),"myconfig")

but what am I supposed to do on Windows? I think a clean solution would be to create a file-like object that reads and writes to the registry, is it?

Kind regards,
Karsten.

-- 


Echte DSL-Flatrate dauerhaft für 0,- Euro*. Nur noch kurze Zeit!
"Feel free" mit GMX DSL: http://www.gmx.net/de/go/dsl


More information about the Tutor mailing list