use2to3 warnings

26 views
Skip to first unread message

Aaron Meurer

unread,
Dec 23, 2011, 8:46:20 AM12/23/11
to sy...@googlegroups.com
The use2to3 script, near the end, prints the following in the latest master:

RefactoringTool: ### In file py3k-sympy/examples/intermediate/sample.py ###
RefactoringTool: Line 78: You should use 'operator.mul(x, numRows, 0)' here.
RefactoringTool: Line 81: You should use 'operator.mul(y, numCols, 1)' here.
RefactoringTool: ### In file py3k-sympy/sympy/integrals/transforms.py ###
RefactoringTool: Line 488: You should use 'operator.mul(True)' here.
RefactoringTool: Line 488: You should use 'operator.mul(False)' here.
RefactoringTool: ### In file py3k-sympy/sympy/physics/mechanics/kane.py ###
RefactoringTool: Line 165: You should use a for loop here
RefactoringTool: Line 187: You should use a for loop here

Now, the last two are
http://code.google.com/p/sympy/issues/detail?id=2936, and I think it's
fine. My question is about the operator.mul ones.

The respective lines are for sample.py:

78 X = repeat(x, numRows, 0)
81 Y = repeat(y, numCols, 1)

and for transforms.py

488 args = zip(numer, repeat(True)) + zip(denom, repeat(False))

In sample.py, repeat is numpy.repeat(), which repeats elements of an
array. In transforms.py, repeat() is itertools.repeat(), which
creates an iterator that repeats the same element an arbitrary number
of times (or n times, if a second argument is given, which it's not
here). This exists in Python 2 and Python 3.

Both of these are left alone by 2to3, except that zip() is wrapped in
list() in the transforms.py one.

Does anyone know what 2to3 means here? operator.mul() works like
mul(a, b) => a*b. It takes exactly 2 arguments, which means that both
suggestions could never work. Is this a bug in 2to3?

Aaron Meurer

Reply all
Reply to author
Forward
0 new messages