Python 2to3 Warning What does this mean? … here is a solution to the problem.
Python 2to3 Warning What does this mean?
I’m using a 2to3 conversion script. The only warning I got was:
RefactoringTool: Line 716: You should use 'operator.mul(None)' here.
Line 716 of the original script is:
classes = repeat(None)
I don’t know where I should use operator.mul(None).
repeat()
( link to docs ) The referenced documentation shows that I can pass None
without any problems. So, what should I do?
Solution
2to3 is confused about which repeat
you are referring to. It assumes that you are using operator.repeat
:: in Python 2
Help on built-in function repeat in module operator:
repeat(...)
repeat(a, b) -- Return a * b, where a is a sequence, and b is an integer.
Instead of itertools.repeat.
Honestly, it’s not a good guess because operator.repeat
has two arguments, but that’s what it’s guessing. You can see the transformations listed in the docs
You can use fully qualified itertools.repeat
or ignore it to avoid warnings.