In the main shell of IDLE, errors always return a line number but the development environment doesn’t even have line numbers. Is there anyway to turn on line numbers?
回答 0
3.8版或更高版本:
要在当前窗口中显示行号,请转到,Options然后单击Show Line Numbers。
要自动显示他们,去Options> Configure IDLE> General并检查Show line numbers in new windows框。
If you are trying to track down which line caused an error, if you right-click in the Python shell where the line error is displayed it will come up with a “Go to file/line” which takes you directly to the line in question.
As it was mentioned by Davos you can use the IDLEX
It happens that I’m using Linux version and from all extensions I needed only LineNumbers. So I’ve downloaded IDLEX archive, took LineNumbers.py from it, copied it to Python’s lib folder ( in my case its /usr/lib/python3.5/idlelib ) and added following lines to configuration file in my home folder which is
~/.idlerc/config-extensions.cfg:
Line numbers were added to the IDLE editor two days ago and will appear in the upcoming 3.8.0a3 and later 3.7.5. For new windows, they are off by default, but this can be reversed on the Setting dialog, General tab, Editor section. For existing windows, there is a new Show (Hide) Line Numbers entry on the Options menu. There is currently no hotkey. One can select a line or bloc of lines by clicking on a line or clicking and dragging.
Some people may have missed Edit / Go to Line. The right-click context menu Goto File/Line works on grep (Find in Files) output as well as on trackbacks.
As @StahlRat already answered. I would like to add another method for it. There is extension pack for Python Default idle editor Python Extensions Package.