Issue2899
Created on 2008-05-17 12:30 by bhy, last changed 2022-04-11 14:56 by admin. This issue is now closed.
| Messages (7) | |||
|---|---|---|---|
| msg66993 - (view) | Author: Haoyu Bai (bhy) | Date: 2008-05-17 12:30 | |
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! |
|||
| msg77320 - (view) | Author: David W. Lambert (LambertDW) | Date: 2008-12-08 16:19 | |
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
'''
|
|||
| msg77329 - (view) | Author: Armin Ronacher (aronacher) * ![]() |
Date: 2008-12-08 17:01 | |
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. |
|||
| msg77330 - (view) | Author: David W. Lambert (LambertDW) | Date: 2008-12-08 17:10 | |
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?". |
|||
| msg81960 - (view) | Author: Stephen J. Turnbull (sjt) * ![]() |
Date: 2009-02-13 18:33 | |
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. |
|||
| msg81966 - (view) | Author: Benjamin Peterson (benjamin.peterson) * ![]() |
Date: 2009-02-13 19:22 | |
I disagree. That is the role of -3 warnings. Static analysis is too limited to get into issuing warnings with. |
|||
| msg114622 - (view) | Author: Georg Brandl (georg.brandl) * ![]() |
Date: 2010-08-22 00:18 | |
I guess this will not happen then. |
|||
| History | |||
|---|---|---|---|
| Date | User | Action | Args |
| 2022-04-11 14:56:34 | admin | set | github: 47148 |
| 2019-12-31 16:49:19 | serhiy.storchaka | link | issue39172 superseder |
| 2010-08-22 00:18:24 | georg.brandl | set | status: open -> closed nosy:
+ georg.brandl resolution: wont fix |
| 2009-02-13 19:22:25 | benjamin.peterson | set | assignee: collinwinter -> messages: + msg81966 nosy: + benjamin.peterson |
| 2009-02-13 18:33:05 | sjt | set | nosy:
+ sjt messages: + msg81960 |
| 2008-12-08 17:10:54 | LambertDW | set | messages: + msg77330 |
| 2008-12-08 17:01:48 | aronacher | set | messages: + msg77329 |
| 2008-12-08 16:19:21 | LambertDW | set | nosy:
+ LambertDW messages: + msg77320 |
| 2008-12-08 15:04:20 | aronacher | set | nosy: + aronacher |
| 2008-05-17 17:05:13 | benjamin.peterson | set | title: Fixes find, rfind, etc in 'string' module -> Fixers find, rfind, etc in 'string' module |
| 2008-05-17 12:30:16 | bhy | create | |

