declaration of variables?

Andrew Bennetts andrew-pythonlist at
Mon Feb 17 00:33:32 CET 2003

On Sun, Feb 16, 2003 at 09:36:00PM +0100, Andr? Jonsson wrote:
> Jp Calderone wrote:
> >
> >  I don't understand what this even means.  If the error isn't 
> >  *detectable*,
> >it obviously isn't even an error.
> Hmm, how about this example: if a given function sorts some list, if there 
> is an error in there that doesn't cause a run-time error. How is it 
> possible to detect this without having to write the whole routine once more 
> and compare the results? (which, of course, is an error-prone process).

def test_sorted(seq):
    prev = seq[0]
    for elem in seq[1:]:
        assert elem >= prev
        prev = elem


More information about the Python-list mailing list