You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Changing the imports only is straightforward, but I'm having trouble detecting and changing future uses of the variables, without also clobbering user-defined variables with the same names.
I notice some of the current fixers have similar problems, for example the itertools fixer changes:
def imap(): pass
imap()
to
def imap(): pass
map()
This patch is a little smarter than that, but it only detects top-level definitions. For example, the lowercase in
class Foo:
def __init__(self):
self.lowercase = "blargh"
still gets renamed.
I can work on this more, but would like to know:
a) whether this fix is still wanted
b) how smart it needs to be
c) whether my approach is reasonable. I feel like there should be an easier way.
superluser commented on Sep 9, 2014
superlusermannequin
Mannequin
More actions
...
d) how to format code :\
aldwinaldwin commented on Jul 18, 2019
aldwinaldwinmannequin
Mannequin
More actions
there were many small issues with the patch, improved as good as possible the FixString to catch import as, from string import * and import string
did not include the FixStringImports as it's not a necessity to work in Python3
indeed, some uses of the constant names that are user-defined will also rename, only when it's in a import string. Added a Caution in the documentation. Still, when all are changed, it should not affect the Python3 version, will just work with the renamed variable name.
Activity
ezio-melotti commentedon Oct 27, 2011
They should be renamed to ascii_*.
BreamoreBoy commentedon Jun 28, 2014
@ezio can you prepare a patch for this?
superluser commentedon Sep 9, 2014
Changing the imports only is straightforward, but I'm having trouble detecting and changing future uses of the variables, without also clobbering user-defined variables with the same names.
I notice some of the current fixers have similar problems, for example the itertools fixer changes:
to
This patch is a little smarter than that, but it only detects top-level definitions. For example, the lowercase in
still gets renamed.
I can work on this more, but would like to know:
a) whether this fix is still wanted
b) how smart it needs to be
c) whether my approach is reasonable. I feel like there should be an easier way.
superluser commentedon Sep 9, 2014
...
d) how to format code :\
aldwinaldwin commentedon Jul 18, 2019
there were many small issues with the patch, improved as good as possible the FixString to catch
import as,from string import *andimport stringdid not include the FixStringImports as it's not a necessity to work in Python3
indeed, some uses of the constant names that are user-defined will also rename, only when it's in a
import string. Added aCautionin the documentation. Still, when all are changed, it should not affect the Python3 version, will just work with the renamed variable name.