[portland] Step Value in range()
kirby.urner at gmail.com
Fri May 2 18:40:24 CEST 2008
The popular Numeric package, also NumPy, has arange as a built-in,
allowing just what you suggest.
I like installing VPython (Visual Python) from VPython.org, as that'll
give you a working Numeric right out of the box, plus these other cool
tools, including plots (very simple, but there're plenty of other
add-ons for fancy).
Relevant (sort of):
Or do stuff like:
for x in [(1.00 + n * 0.01) for n in range(11)]
>>> [(1.00 + n * 0.01) for n in range(11)]
[1.0, 1.01, 1.02, 1.03, 1.04, 1.05, 1.0600000000000001,
1.0700000000000001, 1.0800000000000001, 1.0900000000000001,
On Fri, May 2, 2008 at 9:00 AM, Rich Shepard <rshepard at appl-ecosys.com> wrote:
> Is it possible to write a range() call with a less-than-integral step?
> Specifically, I would like to call range(0.0, 100.0, 0.1). It seems this is
> not allowed; only integers need apply.
> Any way of using floats in range()?
> Richard B. Shepard, Ph.D. | Integrity Credibility
> Applied Ecosystem Services, Inc. | Innovation
> <http://www.appl-ecosys.com> Voice: 503-667-4517 Fax: 503-667-8863
> Portland mailing list
> Portland at python.org
More information about the Portland