[Tutor] all elements equal in tuple or list
jeff at ccvcorp.com
Fri Nov 19 04:23:00 CET 2004
Jeff Shannon wrote:
> Kent Johnson wrote:
>> I decided to write a version of this that behaves 'correctly' for all
>> inputs. What 'correct' means to me is, if the input is not iterable,
>> the function raises an exception; if the input is an empty iterable,
>> the function returns True; otherwise it compares the first element to
>> all the others and reports the result.
> So what's the result if you pass in an iterable of length 1?
> I *think* (from eyeballing -- I'm too lazy to type it in and try it ;)
> ) that it will return True, and it seems to me that that is probably
> the correct behavior (especially if it's correct for a zero-length
> iterable), but it's a corner case that probably deserves some mention.
Nevermind, looking a little closer now I see that this is covered in
your unit tests. (And that you are, indeed, expecting it to behave in
the same way that I did.)
More information about the Tutor