wormwood_3 wrote:
> Kent,
>
> You replied with the following some time ago regarding a question I asked
> about optimizing a loop:
>
>>> You should try an optimized for loop:
>>> append_ = self.potdomains.append_
>>> s1_ = suffix1
>>>
Kent,
You replied with the following some time ago regarding a question I asked about
optimizing a loop:
>> You should try an optimized for loop:
>> append_ = self.potdomains.append_
>> s1_ = suffix1
>> s2_ = suffix2
>>
wormwood_3 wrote:
> I ran a few tests, with the following results:
>
> 1. Timing using the time module:
>* Using for loop, src code:
> import time
> start = time.time()
> for word in self.dictcontents:
> se
I ran a few tests, with the following results:
1. Timing using the time module:
* Using for loop, src code:
import time
start = time.time()
for word in self.dictcontents:
self.potdomains.append(word + suffix
>I think what you have is pretty clear. I can't think of a way to do this
>with a single list comprehension because you add two items to the list
>each time through the loop. You could use a list comp and a generator
>expression, but the order of entries in the result will be different:
>self.po
wormwood_3 wrote:
> Hello tutors,
>
> I am trying to understand the best cases in which to use for loops,
list comprehensions, generators, and iterators. I have a rather simple
process that I made initially as a for loop:
>
> self.potdomains = []
> for word in self.dictcontents:
>
Hello tutors,
I am trying to understand the best cases in which to use for loops, list
comprehensions, generators, and iterators. I have a rather simple process that
I made initially as a for loop:
self.potdomains = []
for word in self.dictcontents:
self.potdomains.a