How/where to store calibration values - written by program A, read by program B

Barry Scott barry at barrys-emacs.org
Wed Dec 6 06:35:04 EST 2023



> On 6 Dec 2023, at 09:32, Chris Green via Python-list <python-list at python.org> wrote:
> 
> My requirement is *slightly* more complex than just key value pairs,
> it has one level of hierarchy, e.g.:-
> 
>    KEY1:
>      a: v1
>      c: v3
>      d: v4
>    KEY2:
>      a: v7
>      b: v5
>      d: v6
> 
> Different numbers of value pairs under each KEY.

JSON will allow you to nest dictionaries.

{
    'KEY1': {
        'a': v1
        'c': v3
        'd': v4
    }
    'KEY2': {
         'a': v7
         'b': v5
         'd': v6
    }
}

Personally I would not use .ini style these days as the format does not include type of the data.

Also I would not use the ast.literal_eval as it makes debugging errors in the data harder.

Barry



More information about the Python-list mailing list