Steven D'Aprano wrote: > On Thu, 23 Feb 2006 12:04:38 -0700, Bob Greschke wrote: > > >> try: > >> i = a.find("3") > >> print "It's here: ", i > >> except NotFound: > >> print "No 3's here" > > > > Nuts. I guess you're right. It wouldn't be proper. Things are added or > > proposed every day for Python that I can't even pronounce, but a simple 'if > > (I = a.find("3")) != -1' isn't allowed. Huh. It might be time to go back > > to BASIC. :) > > There are *reasons* why Python discourages functions with side-effects. > Side-effects make your code hard to test and harder to debug. >
>>> "test".index("a") Traceback (most recent call last): File "<pyshell#0>", line 1, in -toplevel- "test".index("a") ValueError: substring not found >>> "test".find("a") -1 -- http://mail.python.org/mailman/listinfo/python-list