[Tutor] Flatten a list in tuples and remove doubles
Francesco Loffredo
fal at libero.it
Sat Jul 28 23:35:10 CEST 2012
Il 28/07/2012 19:43, Steven D'Aprano wrote:
> Francesco Loffredo wrote:
>
>> but I must avoid reading my function again, or I'll find some more bugs!
>
> Perhaps you should run your function, and test it.
Of course I did. Just not as thoroughly as I would if this were a job
commitment. Unfortunately, I don't know anything about the possible
contents of PyProg's list, so my testing can only be partial.
I think my function answers the question, though.
>
> Finding bugs is not the problem. Once you find them, you can fix them.
> It is the bugs that you don't know about that is the problem.
Absolutely. Ignorance is Nr.1 cause of software failure. But I'm not
sure that a complete, fully tested and robust function would be proper
in this tutoring environment, unless the OP had asked about unit testing
or proven software reliability. The many lines of code needed to take
care of all possible input cases could even make more difficult for
him/her to understand how that function solves the problem. At first, I
wrote flatten(inlist) without any error testing. Then I added a couple
of lines, just to show that input control is a Good Thing. And every
time I looked at it, some more controls asked for being coded... but I
wanted to stop at some point. If you'd like to show us what can be done
to really make it rock-solid, feel free and welcome! ;-))
Francesco
More information about the Tutor
mailing list