次のようなものを書くことができるHaskellの「let」式に相当するPythonはありますか?
list2 = [let (name,size)=lookup(productId) in (barcode(productId),metric(size))
for productId in list]
そうでない場合、最も読みやすい代替手段は何ですか?
let 構文を明確にするために追加されました。
x = let (name,size)=lookup(productId) in (barcode(productId),metric(size))
と同等です
(name,size) = lookup(productId)
x = (barcode(productId),metric(size))
ただし、2 番目のバージョンは、リスト内包表記ではうまく機能しません。