python pdb lambda function global name error

旧城冷巷雨未停 提交于 2019-12-05 07:03:15

I can confirm this issue with Python 2.7. There is a bug report for Python 3 which suggests a workaround: interact at the pdb prompt drops you into an interactive session which is populated with globals() and locals() and your lambda should work as expected.

pdb isn't a full python shell, and intercepts a lot of things. But adding a print in front of it should work:

print max(range(len(test)),key=lambda i: test[i])
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!