PEP-8, Line Length, And All That

2023-01-20 Thread Thomas Passin
In another thread ("Improvement to imports, what is a better way ?") there was a lot of talk about line length, PEP-8, etc. I realized that one subject did not really come up, yet it can greatly affect the things we were talking about. I'm referring to the design of the functions, methods, an

Re: ok, I feel stupid, but there must be a better way than this! (finding name of unique key in dict)

2023-01-20 Thread Rob Cliffe via Python-list
On 20/01/2023 15:29, Dino wrote: let's say I have this list of nested dicts: [   { "some_key": {'a':1, 'b':2}},   { "some_other_key": {'a':3, 'b':4}} ] I need to turn this into: [   { "value": "some_key", 'a':1, 'b':2},   { "value": "some_other_key", 'a':3, 'b':4} ] Assuming that I believe t

Re: ok, I feel stupid, but there must be a better way than this! (finding name of unique key in dict)

2023-01-20 Thread Oscar Benjamin
On Fri, 20 Jan 2023 at 17:30, Dino wrote: > > let's say I have this list of nested dicts: > > [ >{ "some_key": {'a':1, 'b':2}}, >{ "some_other_key": {'a':3, 'b':4}} > ] > > I need to turn this into: > > [ >{ "value": "some_key", 'a':1, 'b':2}, >{ "value": "some_other_key", 'a':3, '

Re: ok, I feel stupid, but there must be a better way than this! (finding name of unique key in dict)

2023-01-20 Thread Jon Ribbens via Python-list
On 2023-01-20, Dino wrote: > > let's say I have this list of nested dicts: > > [ >{ "some_key": {'a':1, 'b':2}}, >{ "some_other_key": {'a':3, 'b':4}} > ] > > I need to turn this into: > > [ >{ "value": "some_key", 'a':1, 'b':2}, >{ "value": "some_other_key", 'a':3, 'b':4} > ] [{"v

Re: ok, I feel stupid, but there must be a better way than this! (finding name of unique key in dict)

2023-01-20 Thread Dino
On 1/20/2023 11:06 AM, Tobiah wrote: On 1/20/23 07:29, Dino wrote: This doesn't look like the program output you're getting. you are right that I tweaked the name of fields and variables manually (forgot a couple of places, my bad) to illustrate the problem more generally, but hopefully y

Re: ok, I feel stupid, but there must be a better way than this! (finding name of unique key in dict)

2023-01-20 Thread Tobiah
On 1/20/23 07:29, Dino wrote: let's say I have this list of nested dicts: [   { "some_key": {'a':1, 'b':2}},   { "some_other_key": {'a':3, 'b':4}} ] I need to turn this into: [   { "value": "some_key", 'a':1, 'b':2},   { "value": "some_other_key", 'a':3, 'b':4} ] This doesn't look like

ok, I feel stupid, but there must be a better way than this! (finding name of unique key in dict)

2023-01-20 Thread Dino
let's say I have this list of nested dicts: [ { "some_key": {'a':1, 'b':2}}, { "some_other_key": {'a':3, 'b':4}} ] I need to turn this into: [ { "value": "some_key", 'a':1, 'b':2}, { "value": "some_other_key", 'a':3, 'b':4} ] I actually did it with: listOfDescriptors = list() for cd