0

I have a program which takes some data and generates a graphic, and some details of the graphic are unique to said graphic and are currently being stored in a manually created dictionary which is just read from at runtime. Is there a standard to which I can create more universal config files that aren't hacked together?

Gerald
  • 166
  • 1
  • 13

1 Answers1

0

You should use a JSON (or YAML) file to store your configuration data. See also Where to store application data (non-user specific) on Linux (contrary to title the article actually covers more than Linux).

Allan Wind
  • 23,068
  • 5
  • 28
  • 38
  • You can use a plain python file to store data for importing. Why load and parse another file? – OneCricketeer Dec 19 '20 at 16:28
  • @OneCricketeer with json or the like is easier to modify at runtime – Copperfield Dec 19 '20 at 21:31
  • Python has a pickle library for object serialization @OneCricketeer but that is deprecated per documentation in favor of JSON. In either case you end up with a dict, manipulate it as needed, and write it out again. – Allan Wind Dec 20 '20 at 18:34
  • @Allan I wasn't referring to pickle, just a standard python file to import variables from. Most Flask/Django projects, for example have a config.py – OneCricketeer Dec 21 '20 at 01:07