list (range) syntax

Ryan Ginstrom software at ginstrom.com
Wed Oct 24 21:17:26 EDT 2007


> On Behalf Of Steven D'Aprano
> Because in common English, counting starts at 1 and ranges 
> normally include both end points (that is, it is a "closed" 
> interval). If you say "I'll be away from the 4th to the 7th" 
> and then turn up on the 7th, nearly everyone will wonder why 
> you're back a day early.

Actually, I think this illustrates the point about confusion, because in the
United States at least, "the 4th to the 7th" will not necessarily include
the 7th. That's why it's common to use circumlocutions like "the 4th through
the 7th" and "the 4th to the 7th, inclusive" when one wants to be sure.

At any rate, I also think that having range(1, 10) or a similar construct
mean one to ten (inclusive <g>) is a bad idea. Ruby's philosophy is
obviously different, which is probably fine as long as you know your
tradeoffs.

Regards,
Ryan Ginstrom




More information about the Python-list mailing list