how to modify code while debugging it without having to stop and then restart debugger

Steven D'Aprano steve at REMOVETHIScyber.com.au
Wed Nov 9 11:37:26 EST 2005


On Tue, 08 Nov 2005 13:38:28 -0500, python wrote:

> thanks for all that have replied so far.
> i still find it __very__ hard to believe that i cannot edit code inside a function while debugging it.

You write a function:

def myfunct(s):
    # input arg s is a string
    foo = s*3
    bar = s.upper() + foo   # LINE 2
    blob = foo.lower() + bar
    return blob

You enter the debugger and single-step to the marked line LINE 2. Then you
edit the code to this:

def myfunct(n):
    # input arg n is an int
    foo = n + 1
    bar = foo*2   # LINE 2
    blob = foo**bar
    return blob

What should Python do when you step the debugger, and why is it useful?




> as i mentioned even micro$soft can do this using statically type languages like visual basic and csharp.
> also, both visualbasic and csharp have goto statements, which i do to not use in final code but can be real handy when 
> used with the ability to change debugged code on the fly while inside the function being debugged.

Better and better. Yes, I can see how the ability to jump around a
function on the fly would really help you understand how the function is
supposed to work when you take the gotos out.



> for example,
> if i am inside a function and there is some an error on a line and that is where the debugger is currently pointing at,
> i simple copy and paste the bad code line just below the actual code line.
> i fix this copied code line.
> then i just turn the bad line into a comment line and the debugger will move the current focus to the next time, which 
> is the fixed code.
> 
> how can such a dynamic language like python not be able to do this.

Do you try to ignore the syntax and grammar of the programming language
you are coding in too, or only English?


[snip]

>> there are several applications that can do this.
>> in fact, the free version of the visual studio 2005, which is free, have this ability.

Just out of curiosity, how much is the free version of Visual Studio 2005?


-- 
Steven.




More information about the Python-list mailing list