|
From: Bill B. <wb...@gm...> - 2006-02-14 02:54:20
|
On 2/11/06, Gary Ruben <gr...@bi...> wrote: > > Sasha wrote: > > On 2/10/06, Gary Ruben <gr...@bi...> wrote: > >> ... I must say that Travis's > >> example numpy.r_[1,0,1:5,0,1] highlights my pet hate with python - tha= t > >> the upper limit on an integer range is non-inclusive. > > > > In this case you must hate that an integer range starts at 0 (I don't > > think you would want len(range(10)) to be 11). First, I think the range() function in python is ugly to begin with. Why can't python just support range notation directly like 'for a in 0:10'. Or with 0..10 or 0...10 syntax. That seems to make a lot more sense to me tha= n having to call a named function. Anyway, that's a python pet peeve, and python's probably not going to change something so fundamental... Second, sometimes zero-based, non-inclusive ranges are handy, and sometimes one-based inclusive ranges are handy. For array indexing, I personally lik= e zero based. But sometimes I just want a list of N numbers like a human would write it, from 1 to N, and in those cases it seems really odd for N+1 to show up. This is a place where numpy could do something. I think it would be nice i= f numpy had something like an 'irange' (inclusive range) function to complement the 'arange' function. They would act pretty much the same, except irange(5) would return [1,2,3,4,5], and irange(1,5) would return [1,2,3,4,5]. Anyway, I think I'm going to put a little irange function in my setup. --Bill |