python pdb lambda function global name error

前端 未结 2 1821
半阙折子戏
半阙折子戏 2021-01-12 09:13

I was testing a fix using pdb.set_trace() to make sure it worked the way I expected before implementing it and kept getting a weird error.

(Pdb         


        
相关标签:
2条回答
  • 2021-01-12 09:48

    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])
    
    0 讨论(0)
  • 2021-01-12 10:03

    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.

    0 讨论(0)
提交回复
热议问题