[Tutor] Debugging in Python

Alan Gauld alan.gauld at btinternet.com
Mon Nov 16 12:48:00 EST 2015


On 16/11/15 15:42, Chris Warrick wrote:
> On 16 November 2015 at 15:43, Alan Gauld <alan.gauld at btinternet.com> wrote:
>> Thats not an IDE its just a raw interpreter.
>> IDLE is a full IDE that includes a debugger.
>
> It’s an awful piece of garbage that pretends to be an IDE.

Would you care to expand. Its been doing a fair impression
for the past 20 odd years. And in its IDLEX incarnation most
of the niggles have been removed. It's not Eclipse but it
doesn't pretend to be. But for beginners like the OP its
adequate IMHO. Certainly easier than the raw interpreter
prompt.

>> You need to reload the module but sadly there is no simple command to do
>> that in the interpreter. There is in IDLE ("Restart Shell" menu item)
>>
>> So if you use IDLE your issues will be resolved. You can install
>> IDLE3 from the Ubuntu package manager.
>
> No, they won’t. They will be replaced by a much worse and less
> friendly IDE. Please don’t bother installing IDLE and use the normal
> `python3` shell, ipython or bpython.

He's tried the normal shell and that didn't work for him.
iPython and bPython are certainly other more advanced options
but he needs to install them too and both have a steeper
learning curve for the average user than IDLE.

> The correct fix is to exit() from the python3 shell and start it again.

He's tried that and didn't find it satisfactory. That's why
he wants a "better" workflow.

> Alternatively, add some main code at the end of your file and use
> `python3 hlibert.py`:
>
> if __name__ == '__main__':
>      hilbert(3)

That depends on the nature of his module and the type of testing he 
wants to do. He could, I agree, create a new test file that imports 
hilbert and then add his test code there but that loses the 
interactivity of a shell prompt which may be important.

-- 
Alan G
Author of the Learn to Program web site
http://www.alan-g.me.uk/
http://www.amazon.com/author/alan_gauld
Follow my photo-blog on Flickr at:
http://www.flickr.com/photos/alangauldphotos




More information about the Tutor mailing list