namespace issue?

Michael Powe michael at trollope.org
Fri Jun 22 01:55:30 EDT 2001


>>>>> "Pierre" == Pierre Fortin <pfortin at pfortin.com> writes:

    >> So now the question is, 'why'?  Am I misusing the string.find()
    >> function? Okay, string.find() returns -1 when the string is not
    >> found, which would seem to be what I expected, a false result.
    >> Maybe python doesn't treat -1 as false?  Well, I'll try being
    >> explicit and testing for -1 return.  I probably have just
    >> confused myself hopelessly.

    Pierre> Sometimes -1 is used for failure; BUT -1 is NOT false...
    Pierre> in those cases, you can simply add 1 to the return to
    Pierre> force a failure to return 0 (false)...

Well, I just used a variable to catch the return value of the
string.find() and checked it for -1, but I must admit that seems
clumsy to me.  OTOH, after doing a little research, I see that I was
twice in error, for I was thinking that in C, TRUE was any POSITIVE
nonzero value, whereas it turns out that's wrong, too.  So, I would
have gotten the same result in C.  Error compounded by error.  Yikes!

Thanks for the help.

mp

-- 
  Michael Powe                                 Portland, Oregon USA
'Unless we approve your idea, it will not be permitted, it will not be
allowed.'  -- Hilary Rosen, President, Recording Industry Association
of America



More information about the Python-list mailing list