>
>> Second question is more of a performance question:
>>
>> I don't suspect a "large" # of items in the to_do list, so I *think*
>> that it would be better to just have one SQL statement and then loop
>> through the results 10 times to get the first few records rather than
>> having a seperate sql statement as I have shown here.  I'm too new at
>> python to have a feel for the *right* way to go about this part
>>
>> Could someone point me in the right direction please?
>>
>
As to your second question, I had the same question a few days ago that the
folks here helped me out with.  if you have a list of items you can limit
the loop to get just the first ten items like this:

for x in list_of_results[:10]
     do something with x...

If your object does not easily lend itself to applying a slice, then look
into the itertools module and the islice() method which can help you get and
iterable list from a normaly non-iterable source, like this:

import itertools
for x in itertools.islice(results, 0, 10)
    do something with x...


-Bill
_______________________________________________
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor

Reply via email to