[Python-ideas] [Python-Dev] Inclusive Range
fuzzyman at voidspace.org.uk
Tue Oct 5 16:51:20 CEST 2010
On 05/10/2010 15:33, Alexander Belopolsky wrote:
> On Tue, Oct 5, 2010 at 9:16 AM, Michael Foord<fuzzyman at voidspace.org.uk> wrote:
>> ... Perhaps I should have been clearer; it is only the
>> behaviour of range(x, y) that I've found people-new-to-python confused by.
> Teach them about range(x, y, z) and once you cover negative z they
> will stop complaining about range(x, y). :-)
Well, it probably doesn't help (for those coming to Python from
languages other than C) that some languages do-the-right-thing with
ranges. <0.5 wink>
=> [1, 2, 3]
All the best,
> At least you don't have to deal with range vs. xrange in 3.x anymore.
> IMO, range([start,] stop[, step]) is one of the worst interfaces in
> python. Is there any other function with an optional *first*
> argument? Why range(date(2010, 1, 1), date(2010, 2, 1), timedelta(1))
> cannot be used to produce days in January? Why range(2**300)
> succeeds, but len(range(2**300)) raises OverflowError?
> No, I don't think much can be done about it. Py3k has already done
> everything that was practical about improving range(..).
More information about the Python-ideas