Re: [Tutor] replacing a loop

2019-06-24 Thread Mats Wichmann
On 6/24/19 4:24 PM, johnf wrote: > Thank you - it worked!  I'm glad you are no longer sleepy! > > Actually I wanted the naming to remain consistent with the other loops > > So the name of the function/method (it is in a class) caused the use of > the underscore > > locChoices == location

Re: [Tutor] replacing a loop

2019-06-24 Thread johnf
Thank you - it worked!  I'm glad you are no longer sleepy! Actually I wanted the naming to remain consistent with the other loops So the name of the function/method (it is in a class) caused the use of the underscore locChoices == location choices def locChoices(self) cause me to use

Re: [Tutor] replacing a loop

2019-06-24 Thread David L Neil
Hi John, On 25/06/19 4:15 AM, johnf wrote: Hi folks, I have the following loop (actually repeated many times ) def locChoices(self):     locDS = self.eslocation.getDataSet()     loc_Choices=['']     locKeys=[0]     for row in locDS:    

Re: [Tutor] replacing a loop

2019-06-24 Thread johnf
Actually I do not see a reply from Peter??  I don't have a clue what was said. I realize that performance is not a big issue in this case - of course an increase in speed is always welcome.  I was more interested in a better understanding of the list comprehensions.  Since I have so many

Re: [Tutor] Python type annotation question

2019-06-24 Thread Mats Wichmann
On 6/24/19 12:48 PM, Arup Rakshit wrote: > I am little experimenting with Python type annotation today. I wrote a simple > class as below: > from datetime import date class Person: > ... dob: date > ... def __init__(self, dob): > ... self.dob = dob > ...

[Tutor] Python type annotation question

2019-06-24 Thread Arup Rakshit
I am little experimenting with Python type annotation today. I wrote a simple class as below: >>> from datetime import date >>> class Person: ... dob: date ... def __init__(self, dob): ... self.dob = dob ... >>> Person(11) <__main__.Person object at 0x10e078128> >>> p =

Re: [Tutor] replacing a loop

2019-06-24 Thread Mats Wichmann
On 6/24/19 10:15 AM, johnf wrote: . > > Since I use a lot of similar loops to populate many dropdown controls I > started investigating the use of list comprehensions.  But I can't > figure out how to use them in this loop and wonder if it will improve > the performance. To amplify a tiny bit

Re: [Tutor] replacing a loop

2019-06-24 Thread Peter Otten
johnf wrote: > Hi folks, > > > I have the following loop (actually repeated many times ) If you have repetetive code look into ways to parameterize it, like def choices(rows, choices_column, keys_column): ... > > def locChoices(self): > locDS = self.eslocation.getDataSet() >

[Tutor] replacing a loop

2019-06-24 Thread johnf
Hi folks, I have the following loop (actually repeated many times ) def locChoices(self):     locDS = self.eslocation.getDataSet()     loc_Choices=['']     locKeys=[0]     for row in locDS:     loc_Choices.append(row['facility'])     locKeys.append(row['pkid'])