processing / processing/libprocessing

Naming collision between Processing `map()` and Python `map()`

未關閉
#131 3 則留言 1 個 reaction 已指派 0 人 在 GitHub 檢視

還沒有人認領這個 Issue。

主要語言
Rust
星號
69
分支
14
平均合併
15 天 22 小時
30 天內合併 PR
3

描述

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.

貢獻指南

這個儲存庫沒有索引到貢獻指南

從這裡開始

  1. 先讀完整個 Issue,再讀專案的貢獻指南。
  2. 在 Issue 下留言說明你要接手 —— 這能避免兩個人做同樣的事。
  3. Fork 儲存庫,在一個分支上完成修改。
  4. 送出 Pull Request,並在描述裡引用這個 Issue 編號。

研究方向

從 issue 中描述的陣列範例和 map() 衝突開始,然後將 PAppletJythonDriver.java 中所參照的 processing.py dispatch 與 py5 的 remap() API 進行比較。判斷 libprocessing 應採用哪種命名或 dispatch 行為,並考量其對 Python 內建函式相容性的影響。當選定的 API 能夠無歧義地解決該範例,並已相應地完成文件撰寫或測試時,即視為完成。

由索引模型根據 Issue 內容生成。

評估

技術堆疊
python, rust
領域
api
Issue 類型
功能
難度
5/5
預估耗時
一週以上
活躍度
冷清
描述清晰度
基本清楚
新手友好度
38/100

把新 issue 寄到你的電子郵件信箱

精選適合新手參與的 GitHub issue 摘要。