On Wednesday 20 April 2005 12:28 pm, Roy Smith wrote: > Terry Hancock wrote: > >> I used to make "off by one" errors all the time in both C and Fortran, > >> whereas I hardly ever make them in Python. > > Part of the reason may be that most loops over lists involve > iterators,
> both endpoints are mentioned explicitly. C++/STL also uses iterators, > but the syntax is repulsive. That's true of course. It's more likely to show up in manipulating lists or strings. And Python provides a much richer environment for processing strings, so one has to deal with explicit indexing much less. But I still think that I make fewer error per instance of dealing with intervals. It's rare that I even have to think about it much when writing such a thing. Negative indexing also helps a lot. Terry -- Terry Hancock ( hancock at anansispaceworks.com ) Anansi Spaceworks http://www.anansispaceworks.com -- http://mail.python.org/mailman/listinfo/python-list