On Wed, 01 Apr 2009 02:24:45 +0200, Lada Kugis wrote: > I'm coming from fortran and c background so I'm certainly biased by > them. But if you could explain one thing to me: > > in fortran for example: > for i=1,n > goes from 1,2,3,4,...,n > > in python for example: > for i in range(1,n) > goes from 1,2,3,4,...,n-1 > (that is, it goes from 1 up to, but not including n) > > Why is that so ? What were the reasons for that "not including" part ? > It troubles me greatly, and I cannot see it's advantages over the > "standard" "up to and including" n.
Why Python (and other languages) count from zero instead of one, and why half-open intervals are better than closed intervals: http://www.johndcook.com/blog/2008/06/26/why-computer-scientists-count-from-zero/ http://www.cs.utexas.edu/users/EWD/transcriptions/EWD08xx/EWD831.html -- Steven -- http://mail.python.org/mailman/listinfo/python-list