Where to put a config file for a compiled Python script?

后端 未结 4 1912
囚心锁ツ
囚心锁ツ 2021-01-21 02:51

This is similar to Where to put a configuration file in Python?, but I\'m asking about scripts compiled/frozen with py2exe or similar on Windows systems. (Namely, this one: Wha

4条回答
  •  礼貌的吻别
    2021-01-21 03:41

    If you are using py2exe to package you script, following your links to the one that describes how to determine the path of the executable seems to be the proper way to go. Where you decide to store your config file relative to the exe is up to you. You can either place it in the root of the application directory (next to the exe) or create a config subdir. Its your choice.

    On linux machines it can sometimes be common to make use of the etc/ locations for config files. OSX you would either use the users plist preferences location, or an etc. But again in any of these platforms you could also use a relative conf file in the apps directory.

    If you were packaging some type of GUI framework, then you could make use of the registry and offer config options through your interface.

提交回复
热议问题