Re: Basic Nested Dictionary in a Loop

2017-04-04 Thread Ganesh Pal
Thanks Peter , Terry and others ! On Tue, Apr 4, 2017 at 12:11 PM, Peter Otten <__pete...@web.de> wrote: > Ganesh Pal wrote: > > >> > >> > >> Whenever you feel the urge to write range(len(whatever)) -- resist that > >> temptation, and you'll end up with better Python code ;) > >> > >> > > Thanks

Re: Basic Nested Dictionary in a Loop

2017-04-03 Thread Peter Otten
Ganesh Pal wrote: >> >> >> Whenever you feel the urge to write range(len(whatever)) -- resist that >> temptation, and you'll end up with better Python code ;) >> >> > Thanks for this suggestion but for my better understanding can explain > this further even Steve did point the same mistake. It's

Re: Basic Nested Dictionary in a Loop

2017-04-02 Thread Terry Reedy
On 4/2/2017 1:59 PM, Ganesh Pal wrote: > 'someone' wrote Whenever you feel the urge to write range(len(whatever)) -- resist that temptation, and you'll end up with better Python code ;) Thanks for this suggestion but for my better understanding can explain this further even Steve did point th

Re: Basic Nested Dictionary in a Loop

2017-04-02 Thread Ganesh Pal
> > > Whenever you feel the urge to write range(len(whatever)) -- resist that > temptation, and you'll end up with better Python code ;) > > Thanks for this suggestion but for my better understanding can explain this further even Steve did point the same mistake. > > Instead of artificially blow

Re: Basic Nested Dictionary in a Loop

2017-04-02 Thread Ganesh Pal
On Sun, Apr 2, 2017 at 10:35 PM, Steve D'Aprano wrote: > > Why is payment a string? > > Yes it should be int > > > The value salary3 ,salary4,salary4 is to be generated in the loop . Iam > > trying to optimize the above code , by looping as shown below > > In the above example, you have strings

Re: Basic Nested Dictionary in a Loop

2017-04-02 Thread Steve D'Aprano
On Mon, 3 Apr 2017 02:13 am, Ganesh Pal wrote: > Dear Python friend > > > I have a nested data dictonary in the below format and I need to store > 1000 of entries which are in teh below format > > X['emp_01']['salary3'] = dict(sex="f", status="single", exp="4", > grade="A",payment="200"

Re: Basic Nested Dictionary in a Loop

2017-04-02 Thread Peter Otten
Ganesh Pal wrote: > Dear Python friend > > > I have a nested data dictonary in the below format and I need to store > 1000 of entries which are in teh below format > > X['emp_01']['salary3'] = dict(sex="f", status="single", exp="4", > grade="A",payment="200") X['emp_01']['salary4']