[Tutor] re: range function

Bruce Sass bsass@freenet.edmonton.ab.ca
Thu, 24 May 2001 00:33:54 -0600 (MDT)


On Wed, 23 May 2001, Bruce Sass wrote:

Here is a mistake I'm not going to make again.

I said...

> Combine the two...
>
> ---8<--- floatrange.py ---
> #!/usr/bin/env python2.0
<...>
>     steps = (stop-start)/step
>     if steps != int(steps):
>         steps = steps + 1.0
>     for i in range(int(steps)):
>         the_range.append(i*step+start)
<...>
> --->8---
>
> output is:
> (1.0, 20.0, 4.55): [1.0, 5.55, 10.1, 14.65, 19.2]

The only problem is I did it while in xemacs, using ^c^c, and the
default python interpreter is 1.5.2 -- the #! was having no effect
'cause xemacs was passing the buffer onto /usr/bin/python.  When I
pointed "python" to "python2.1" I got the ugly representation again.

Since...

>>> 5.5499999999999998 == 5.55
1

...is it anything more than a cosmetic issue when print-ing, e.g., a
list of floats (rather than the items in a list of floats).


- Bruce