"Hasan Diwan" <[EMAIL PROTECTED]> wrote: > On 23/08/06, Josiah Carlson <[EMAIL PROTECTED]> wrote: > > > > ...that looks to have been done by a script, it has inconsistant style > > compared to the code it replaces, etc. > > > > I made the minimal change that implements the functionality suggested, in > terms of find/rfind, they return -1. The least painful way to replace it > with index is: > > try: > i=str.index(foo) > except ValueError: > i = -1 > > As for the plain except clauses, that was just laziness on my part. It's not > meant to be stylistically consistent or beautiful, rather it is meant to be > functional and as a starting point. Feel free to change/rewrite the patch. > The GENERAL CASE, i.e. one that is applicable throughout the code is the > try/except clauses shown above.
If find is to be replaced, it should be replaced with something that isn't as cumbersome to use as index, and shouldn't be done in a bulk replacement attempt; as you have also shown that doing such can lead to unintended new bugs and the possible perpetuation of old bugs. When Raymond Hettinger did the same thing to replace some examples of find with partition, in my first pass over his proposed patch, I also discovered a handful of new and perpetuated bugs, which was in a similar skimming of the patches. I'm also not going to fix the patch because I don't believe that replacing find with index is the correct course of action, for the few reasons I've laid out in the current and previous messages on the topic. - Josiah _______________________________________________ Python-3000 mailing list [email protected] http://mail.python.org/mailman/listinfo/python-3000 Unsubscribe: http://mail.python.org/mailman/options/python-3000/archive%40mail-archive.com
