作者changyuheng (张昱珩)
看板Python
标题[问题] func default value 的 list 没有清掉
时间Sun Jan 18 23:45:49 2015
大家好:
写了一个 DFS 的 function 在这边
http://ideone.com/Kzp5Ac
可以看到当呼叫 dfs_paths(graph, start, goal, path=list()) 时,
若 list 确定为空则结果是正常的。
当我没有传 list 进去时,期待他会透过 default value 生出一份新的,
可是这个 function 居然好像有 cache 的机制,使得结果不正确,请问这是为什麽?
--
http://changyuheng.github.io/
--
※ 发信站: 批踢踢实业坊(ptt.cc), 来自: 220.141.120.44
※ 文章网址: https://webptt.com/cn.aspx?n=bbs/Python/M.1421595954.A.FFD.html
2F:推 timTan: 请看 google 的 python coding style guide 01/19 17:47
3F:→ changyuheng: 请问是指 graph 那边的缩排吗? 01/19 23:53
※ 编辑: changyuheng (36.231.57.170), 01/20/2015 15:00:13