module trace and counts
d at davea.name
Sun Nov 18 03:54:31 CET 2012
On 11/17/2012 08:30 PM, Steven D'Aprano wrote:
> On Sat, 17 Nov 2012 13:37:23 -0500, Dave Angel wrote:
>> On 11/17/2012 12:25 PM, rh wrote:
>>> Is it for or range that is executed 8000 times when I for i in
>> Nothing is executed 8000 times. I figure it at 3998 times.
> Off by one.
> py> len(range(3, 8000, 2))
I should have actually let Python figure it. Instead I knocked off one
because the interval is half-open, and another because it starts at 3.
Then I checked it by subtracting the first from the last and dividing by
2 ( (7999-3)/2 ), but then made the stupid mistake of not adding one
because my interval WAS closed.
More information about the Python-list