[Python-3000] Droping find/rfind?

Guido van Rossum guido at python.org
Thu Aug 24 04:39:29 CEST 2006


I don't find the current attempts to come up with a better substring
search API useful.

We did a lot of thinking about this not too long ago, and the result
was the addition of [r]partition() to 2.5 and the intent to drop
[r]find() from py3k as both redundant with [r]index() and error-prone
(I think I just found another bug in logging.__init__.py:

    def _fixupChildren(self, ph, alogger):
        """
        Ensure that children of the placeholder ph are connected to the
        specified logger.
        """
        #for c in ph.loggers:
        for c in ph.loggerMap.keys():
            if string.find(c.parent.name, alogger.name) <> 0:
                alogger.parent = c.parent
                c.parent = alogger

This is either a really weird way of writing "if not
c.parent.name.startswith(alogger.name):", or a bug which was intending
to write "if alogger.name in c.parent.name:" .

I appreciate the criticism on the patch -- clearly it's not ready to
go in, and more work needs to be put in to actually *improve* the
code, using [r]partition()  where necessary, etc. But I'm strenghtened
in the conclusion that find() is way overused and we don't need yet
another search primitive. TOOWTDI.

-- 
--Guido van Rossum (home page: http://www.python.org/~guido/)


More information about the Python-3000 mailing list