> On 6 Dec 2023, at 09:32, Chris Green via Python-list <python-list@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

-- 
https://mail.python.org/mailman/listinfo/python-list

Reply via email to