Re: Looping using iterators with fractional values
beliavsky_at_aol.com
Date: 01/01/05
- Next message: Alex Martelli: "Re: What can I do with Python ??"
- Previous message: Alex Martelli: "Re: UserDict deprecated"
- In reply to: Mike Meyer: "Re: Looping using iterators with fractional values"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: 1 Jan 2005 14:46:17 -0800
Mike Meyer wrote:
>Or - and much safer when dealing with floating point numbers - iterate
>over integers and generate your float values:
>for j in range(1, 9):
> i = j * .25
> print "%9.2f" % i
I agree with this suggestion. As an historical aside, Fortran had loops
with floating point variables for decades, but in 1995, the first
standard in a while to REMOVE features, this was one of the few things
deleted. The Fortran standards committee is very conservative about
creating backwards incompatibilities, but they must have thought loops
with floating point variables are so error-prone -- and alternatives
with integer counters are so easy to write -- that they put their foot
down. I know the OP is asking about Python, but the principle is the
same.
- Next message: Alex Martelli: "Re: What can I do with Python ??"
- Previous message: Alex Martelli: "Re: UserDict deprecated"
- In reply to: Mike Meyer: "Re: Looping using iterators with fractional values"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Relevant Pages
|