Trying to port the array example (See issue: Port Basics / Arrays / Array #3) and I'm running into this error:
coswave = [abs(cos(map(i, 0, width, 0, pi))) for i in range(width)]
~~~^^^^^^^^^^^^^^^^^^^^
TypeError: 'int' object is not iterable
I suppose this is because Python has its own map() function (a list transformation) different from the map() function in Processing (a linear interpolation function).
Processing.py handles this by wrapping map() and dispatching based on the arguments (see source code). It uses the Processing version when called with five numeric arguments, and otherwise falls back to Python’s built-in. Note: the same approach is used for filter().
By contrast, py5 avoids the conflict by renaming the function to remap() instead.
Trying to port the array example (See issue: Port
Basics/Arrays/Array#3) and I'm running into this error:I suppose this is because Python has its own map() function (a list transformation) different from the map() function in Processing (a linear interpolation function).
Processing.py handles this by wrapping
map()and dispatching based on the arguments (see source code). It uses the Processing version when called with five numeric arguments, and otherwise falls back to Python’s built-in. Note: the same approach is used forfilter().By contrast, py5 avoids the conflict by renaming the function to
remap()instead.