Chris Rebert <c...@rebertia.com> writes: > Python 2.6 (r26:66714, Nov 18 2008, 21:48:52) > [GCC 4.0.1 (Apple Inc. build 5484)] on darwin > Type "help", "copyright", "credits" or "license" for more information. >>>> bool(-1) > True > > str.find() returns -1 on failure (i.e. if the substring is not in the > given string). > -1 is considered boolean true by Python.
That's an odd little quirk... never noticed that before. I just use regular expressions myself. Wouldn't this be something worth cleaning up? It's a little confusing for failure to evaluate to boolean true even if the relationship isn't direct. -- http://mail.python.org/mailman/listinfo/python-list