Tomergt45
Tomergt45

Reputation: 679

Where is the official place to store settings of a python module?

My python module needs to save some configuration files into a disk, is there a standard convention on where to save your module configuration files? one that you won't run into a permission error.

Upvotes: 0

Views: 398

Answers (1)

AdamF
AdamF

Reputation: 2930

You can store these configuration file where ever you want (as long as your python script have the write permission to this directory and no process prevent it from writing to this directory (is not locked by other process)), as long as your module can reach them for parsing or for import if they are a python files.

what are the options:

  1. store them in the same module directory, and import/parse them.
  2. store them in deferent directory and in your python module change the os.path with os.chdir(path) to this dir for parsing.
  3. store them in dir_x and provide the dir_x path to your python script via command line args with sys.argv[1]. or with argparse!

Upvotes: 2

Related Questions