[Tutor] Debugging in Python

Alan Gauld alan.gauld at btinternet.com
Mon Nov 16 09:43:55 EST 2015


On 16/11/15 09:55, Sajjadul Islam wrote:
> Hello forum,
>
> I am trying Python 3.4 on Ubuntu and I am a bit confused with the debugging
> scope of python in general.
>
> I wrote a small function and then I tried to run with the following call:
>
> ///////////////////////////
>
> import hilbert
> hilbert.hilbert(3)
>
> ///////////////////////////
>
> Please note that , I am not using the IDLE IDE. Instead I am using the
> typical IDE that shows up with the command "python3" in the linux command
> line.

Thats not an IDE its just a raw interpreter.
IDLE is a full IDE that includes a debugger.

> I encountered some error in the source , then I fixed it and tried to run
> the module with the above snippet again , but the the error prevails even
> though the error part is commented and the updated version saved.

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.

> Why is it so clumsy ? I believe that there is better way to program in
> python which I am missing ?

Use IDLE :-)
Or any of the other IDEs.

Alternatively use multiple windows.
I personally prefer to have a vim window for editing the code and
a separate terminal for running it. But that assumes I have a
main file and can just type

$ python myfile.py.

In the terminal.

If I'm only creating a module I use the IDLE shell instead of the
terminal window.


-- 
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