Functions like find() rfind() index() rindex() has been removed in Python 3.0. So there should be a 2to3 fix for it. Eg. fix if string.find(s, "hello") >= 0: to if str.find(s, "hello") >= 0: Thank you!
I expect the answer will be that 2to3 cannot know what sort of object "string" names. Bell's theorem, or some such, as I understand it, tells us that you must execute the algorithm to find out what it does, there isn't a short cut. It does seem like 2to3 could assume that you write code with honorable intention, grace, and style and thereby offer a suggestive note. The string module is not an isolated case for such notices. I made a similar request to yours for "file" which is gone in version 3. Unfortunately, code as follows is probably frequent, so we aren't likely to get support for this feature. Maybe here is an opportunity for venture capital! def f(list): ''' argument should be a list. "list" in this scope no longer names __builtins__.list '''
2to3 could handle it, but it would be a lot of work for something unnecessary. You can use "s.replace(a, b)" instead of string.replace(s, a, b) since at least 2.0.
I think the point is to get a message from 2to3 about possible use of feature that is gone. Of course python3 raises an exception when trying to execute the code, but it does leave the user wondering "why did 2to3 report that there are no changes necessary?".
Maybe 2to3 could get a --pedantic or even an --annoying option? I agree that it should be noisy about removed features even if actually fixing this kind of thing would be hard to do reliably.