0

I'm looking to store some individual settings to each user's computer. Things like preferences and a license key. From what I know, saving to the registry could be one possibility. However, that won't work on Mac.

One of the easy but not so proper techniques are just saving it to a settings.txt file and reading that on load.

Is there a proper way to save this kind of data? I'm hoping to use my wx app on Windows and Mac.

User
  • 23,729
  • 38
  • 124
  • 207

2 Answers2

0

Take a look at Data Persistence on python docs. One option a you said could be persist them to a simple text file. Or you can save your data using some serialization format as pickle (see previous link) or json but it will be pretty ineficient if you have several keys and values or it will be too complex.

Also, you could save user preferences in an .ini file using python's ConfigParser module as show in this SO answer.

Finally, you can use a database like sqlite3 which is simpler to handle from your code in order to save and retrieve preferences.

Community
  • 1
  • 1
matagus
  • 6,136
  • 2
  • 26
  • 39
0

There is no proper way. Use whatever works best for your particular scenario. Some common ways for storing user data include:

  • Text files (e.g. Windows INI, cfg files)
  • binary files (sometimes compressed)
  • Windows registry
  • system environment variables
  • online profiles

There's nothing wrong with using text files. A lot of proper applications uses them exactly for the reason that they are easy to implement, and additionally human readable. The only thing you need to worry about is to make sure you have some form of error handling in place, in case the user decides to replace you config file content with some rubbish.

jaho
  • 4,852
  • 6
  • 40
  • 66
  • Exactly, but a few of those are operating system specific. Looking for one that works on all. – User Mar 08 '14 at 19:57