> Seebs <usenet-nos...@seebs.net> writes: > > On 2010-10-13, Chris Rebert <c...@rebertia.com> wrote: > > > For future reference, the significant majority of things in Python > > > raise exceptions upon encountering errors rather than returning > > > error values of some sort. > > > > Yes. I'm getting used to that -- it's a bit of a shift, because I'm > > used to exceptions being *exceptional* -- as in, not a failure mode > > you would expect to see happening. > > From that expectation, it's an even more fundamental shift. Python > encourages (and tends toward) raising exceptions in any exceptional > circumstance — that is, in any circumstance that isn't the usual > behaviour for the function. > > So, for example, an exception (StopIteration) is how iterables signal > that they've finished iterating; but that's not an error, only an > exception. Likewise for the ‘str.index’ example given earlier.
I'd say more succintly that Python uses (at times) exception for flow control. Whether that's elegant or not is debatable. Cheers, Emm -- http://mail.python.org/mailman/listinfo/python-list