Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #33490

Re: module trace and counts

Date 2012-11-17 21:54 -0500
From Dave Angel <d@davea.name>
Subject Re: module trace and counts
References <20121117092502.12c53a8f48072cd249108b47@lavabit.com> <mailman.3777.1353177465.27098.python-list@python.org> <50a83a40$0$29978$c3e8da3$5496439d@news.astraweb.com>
Newsgroups comp.lang.python
Message-ID <mailman.3784.1353207300.27098.python-list@python.org> (permalink)

Show all headers | View raw


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
>>> range(3,8000,2):
>> Nothing is executed 8000 times.  I figure it at 3998 times.
> Off by one.
>
> py> len(range(3, 8000, 2))
> 3999
>
>
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.



-- 

DaveA

Back to comp.lang.python | Previous | NextPrevious in thread | Find similar | Unroll thread


Thread

Re: module trace and counts Dave Angel <d@davea.name> - 2012-11-17 13:37 -0500
  Re: module trace and counts Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2012-11-18 01:30 +0000
    Re: module trace and counts Dave Angel <d@davea.name> - 2012-11-17 21:54 -0500

csiph-web