Re: Printing dict value for possibly undefined key

2023-11-28 Thread Loris Bennett via Python-list
DL Neil writes: > On 11/25/2023 3:31 AM, Loris Bennett via Python-list wrote: >> Hi, >> I want to print some records from a database table where one of the >> fields contains a JSON string which is read into a dict. I am doing >> something like >>print(f"{id} {d['foo']} {d['bar']}") >>

Re: Printing dict value for possibly undefined key

2023-11-28 Thread Loris Bennett via Python-list
duncan smith writes: > On 24/11/2023 16:35, duncan smith wrote: >> On 24/11/2023 14:31, Loris Bennett wrote: >>> Hi, >>> >>> I want to print some records from a database table where one of the >>> fields contains a JSON string which is read into a dict.  I am doing >>> something like >>> >>>   

Re: Printing dict value for possibly undefined key

2023-11-25 Thread DL Neil via Python-list
On 11/25/2023 3:31 AM, Loris Bennett via Python-list wrote: Hi, I want to print some records from a database table where one of the fields contains a JSON string which is read into a dict. I am doing something like print(f"{id} {d['foo']} {d['bar']}") However, the dict does not always

Re: Printing dict value for possibly undefined key

2023-11-25 Thread duncan smith via Python-list
On 24/11/2023 16:35, duncan smith wrote: On 24/11/2023 14:31, Loris Bennett wrote: Hi, I want to print some records from a database table where one of the fields contains a JSON string which is read into a dict.  I am doing something like    print(f"{id} {d['foo']} {d['bar']}") However, the

Re: Printing dict value for possibly undefined key

2023-11-25 Thread duncan smith via Python-list
On 24/11/2023 14:31, Loris Bennett wrote: Hi, I want to print some records from a database table where one of the fields contains a JSON string which is read into a dict. I am doing something like print(f"{id} {d['foo']} {d['bar']}") However, the dict does not always have the same keys,

Printing dict value for possibly undefined key

2023-11-25 Thread Loris Bennett via Python-list
Hi, I want to print some records from a database table where one of the fields contains a JSON string which is read into a dict. I am doing something like print(f"{id} {d['foo']} {d['bar']}") However, the dict does not always have the same keys, so d['foo'] or d['bar'] may be undefined. I