[Tutor] range() or xrange() for non-integers?

Terry Carroll carroll at tjc.com
Sat Sep 13 14:15:39 EDT 2003


On Sat, 13 Sep 2003, Bob Gailer wrote:

> for x in xrange(-8.0, 8.0, 1.0):
>      print x/2

Thanks.

I'd thought of something along those lines, but that seems even worse for
my particular application.  I was going to need to vary the step to find
the optimal one.  (The actual application is to generate points to graph
the x-component of electrical field generated by two particles.)  So My 
first cut might be varying by .5, another by .1, etc.  To have to vary by 
1 and change the start and end points and an inner divisor to compensate 
seems very kludgy to me.

-- 
Terry Carroll        |   "I say to you that the VCR is to the American
Santa Clara, CA      |   film producer and the American public as the 
carroll at tjc.com      |   Boston strangler is to the woman home alone."  
                     |       Jack Valenti, MPAA President
Modell delendus est  |       Testimony before Congress, 1982




More information about the Tutor mailing list