inclusive-lower-bound, exclusive-upper-bound (was Re: Range Operation pre-PEP)
Andrew Maizels
andrew at one.net.au
Thu May 10 17:52:57 EDT 2001
Alex Martelli wrote:
> I disagree. Inclusive-lower-bound, exclusive-upper-bound
> is a VERY important and useful idiom, which we should
> strive to make as widespread as we possibly can: by the
> very fact of being invariably used everywhere lower and
> upper bounds are specified, it helps a LOT against
> off-by-one errors! I first saw it explained in Koenig's
> excellent "C traps and pitfalls" book, by the way.
I can see where consistency is important, but why does Python do the
inclusive-lower-bound, exclusive-upper-bound thing?
>From my point of view, there's one correct behaviour for range(1,5), and
it's NOT [1, 2, 3, 4]!
Andrew.
--
There's only one game in town.
You can't win.
You can't break even.
You can't quit the game. -- The four laws of thermodynamics.
More information about the Python-list
mailing list