Discussion:
How to debug Python IDLE?
ryguy7272
2014-10-15 19:09:50 UTC
Permalink
I'm wondering how to debug code in IDLE Python 3.4. I found this.
http://www.cs.uky.edu/~paulp/CS115F11/notes/debug/debug.html

That looks pretty helpful, but mine is nothing like that. All my controls are greyed out. The debugger does basically...nothing. All I get is messages like this.

[DEBUG ON]
[DEBUG OFF]
[DEBUG ON]
It doesn't debug anything at all.

Any idea what's wrong?
Thanks.
Terry Reedy
2014-10-15 19:22:46 UTC
Permalink
Post by ryguy7272
I'm wondering how to debug code in IDLE Python 3.4. I found this.
Use 3.4.2, which has an important bugfix for debugger.
Post by ryguy7272
http://www.cs.uky.edu/~paulp/CS115F11/notes/debug/debug.html
That looks pretty helpful,
but mine is nothing like that. All my controls are greyed out.
That is normal when you first turn debugger on. You have to load a file
in the editor and then run it (F5). On the site above, the file is
volume.py. The the debugger is 'activated'.
--
Terry Jan Reedy
ryguy7272
2014-10-15 19:36:25 UTC
Permalink
Post by Terry Reedy
Post by ryguy7272
I'm wondering how to debug code in IDLE Python 3.4. I found this.
Use 3.4.2, which has an important bugfix for debugger.
Post by ryguy7272
http://www.cs.uky.edu/~paulp/CS115F11/notes/debug/debug.html
That looks pretty helpful,
but mine is nothing like that. All my controls are greyed out.
That is normal when you first turn debugger on. You have to load a file
in the editor and then run it (F5). On the site above, the file is
volume.py. The the debugger is 'activated'.
--
Terry Jan Reedy
Oh, I didn't know that's how it works. ok. Makes sense. Something is still wrong though. I have a file named 'test_script.py'.

Here's the code:

def showMaxFactor(num):
count = num / 2
while count > 1:
if num % count == 0:
print 'largest factor of %d is %d' % \
(num, count)
break
count -= 1
else:
print num, "is prime"
for eachNum in range(10, 21):
showMaxFactor(eachNum)

With the debugger ON, I hit F5 and get this.
'Expected an indent block'

I wouldn't say that's debugging anything. I can't tell what line is throwing the error, or how to fix it.

Any thoughts?
MRAB
2014-10-15 19:52:17 UTC
Permalink
Post by ryguy7272
Post by Terry Reedy
Post by ryguy7272
I'm wondering how to debug code in IDLE Python 3.4. I found this.
Use 3.4.2, which has an important bugfix for debugger.
Post by ryguy7272
http://www.cs.uky.edu/~paulp/CS115F11/notes/debug/debug.html
That looks pretty helpful,
but mine is nothing like that. All my controls are greyed out.
That is normal when you first turn debugger on. You have to load a file
in the editor and then run it (F5). On the site above, the file is
volume.py. The the debugger is 'activated'.
--
Terry Jan Reedy
Oh, I didn't know that's how it works. ok. Makes sense. Something is still wrong though. I have a file named 'test_script.py'.
count = num / 2
print 'largest factor of %d is %d' % \
(num, count)
break
count -= 1
print num, "is prime"
showMaxFactor(eachNum)
With the debugger ON, I hit F5 and get this.
'Expected an indent block'
I wouldn't say that's debugging anything. I can't tell what line is throwing the error, or how to fix it.
Any thoughts?
The 'print' line is indented the same as the 'if' line.
Terry Reedy
2014-10-16 02:21:34 UTC
Permalink
On 10/15/2014 3:36 PM, ryguy7272 wrote:

Please pay attention to Mark's comment about how to avoid blank line
doubling.
Post by ryguy7272
count = num / 2
print 'largest factor of %d is %d' % \
(num, count)
break
count -= 1
print num, "is prime"
showMaxFactor(eachNum)
With the debugger ON, I hit F5 and get this.
'Expected an indent block'
You saw that in a Syntax Error box.
Post by ryguy7272
I wouldn't say that's debugging anything.
Quite the opposite. Idle checks syntax before running the code since
running the code would produce the same error anyway.
Post by ryguy7272
I can't tell what line is throwing the error, or how to fix it.
When you click OK on the box, the editor window is display with the
error marked in red background. In this case, that should be 'print'
with red background. If you indent print and run again, you should, if
running 3.x, see 'Missing parenthesis...' and another red marking.
--
Terry Jan Reedy
ryguy7272
2014-10-15 20:45:59 UTC
Permalink
Post by ryguy7272
I'm wondering how to debug code in IDLE Python 3.4. I found this.
http://www.cs.uky.edu/~paulp/CS115F11/notes/debug/debug.html
That looks pretty helpful, but mine is nothing like that. All my controls are greyed out. The debugger does basically...nothing. All I get is messages like this.
[DEBUG ON]
[DEBUG OFF]
[DEBUG ON]
It doesn't debug anything at all.
Any idea what's wrong?
Thanks.
Yes. exactly. So why is it throwing an error and how can I truly debug it? Normally, you can step through code line by line, but I don't see any way to do this using Python.

Man, I've been in all kinds of development roles, for over 10 years, using all kinds of languages, and I've never worked with anything as difficult as Python. It seems so simple, but actually nothing works for me. I've read 4 books on Python and I've been working on small snippets of code, for 2 months now. Almost nothing at all has worked for me.
Mark Lawrence
2014-10-15 21:19:47 UTC
Permalink
Post by ryguy7272
Post by ryguy7272
I'm wondering how to debug code in IDLE Python 3.4. I found this.
http://www.cs.uky.edu/~paulp/CS115F11/notes/debug/debug.html
That looks pretty helpful, but mine is nothing like that. All my controls are greyed out. The debugger does basically...nothing. All I get is messages like this.
[DEBUG ON]
[DEBUG OFF]
[DEBUG ON]
It doesn't debug anything at all.
Any idea what's wrong?
Thanks.
Yes. exactly. So why is it throwing an error and how can I truly debug it? Normally, you can step through code line by line, but I don't see any way to do this using Python.
Man, I've been in all kinds of development roles, for over 10 years, using all kinds of languages, and I've never worked with anything as difficult as Python. It seems so simple, but actually nothing works for me. I've read 4 books on Python and I've been working on small snippets of code, for 2 months now. Almost nothing at all has worked for me.
What did you not understand about the answers given by Terry Reedy and
MRAB? Why are you using a debugger, I can't remember the last time I
needed one with Python? Please don't try to fight the language, use the
1000s of man years experience here to make life easier for yourself.
Even if you've no Java experience try reading this
http://dirtsimple.org/2004/12/python-is-not-java.html and this
http://dirtsimple.org/2004/12/java-is-not-python-either.html to get a
feel for Python. If you haven't read the Zen of Python do that as well.
I'll let you look that one up :)

Further would you please access this list via
https://mail.python.org/mailman/listinfo/python-list or read and action
this https://wiki.python.org/moin/GoogleGroupsPython to prevent us
seeing double line spacing and single line paragraphs, thanks.
--
My fellow Pythonistas, ask not what our language can do for you, ask
what you can do for our language.

Mark Lawrence
Loading...