[Tutor] Function design

Dave Angel davea at ieee.org
Tue Oct 27 17:14:58 CET 2009

Benno Lang wrote:
> On Tue, Oct 27, 2009 at 8:21 AM, Dave Angel <davea at ieee.org> wrote:
>> I agree with Luke's comments.  But I'd like to point out an apparent bug (I
>> haven't tried the code, this is just by inspection).
>> You use the test
>>     if '0' in row[.....]
>> that's not going to check for a zero value, it's going to check for a zero
>> digit character somewhere in the value.  So 504 would also be recognized, as
>> well as 540.
> I thought this sounded rather fishy, along the following lines:
> row is a list, so slicing it returns a list, so 'in' should compare
> the list elements (i.e. the strings contained therein) with '0'; this
> seems perfectly normal.
> I have checked, and thankfully the world is not upside down. It would
> only work the way you describe if row was a string, or if 'in' called
> itself recursively when it found a list.
> HTH,
> benno
You are quite right, of course.  I somehow missed that it was a slice, 
and took it instead to be a simple subscript.

But if the file contained  0.00 as one of its items, this code would 
still have the other problem I mentioned.


More information about the Tutor mailing list