<char...@sohu.com> wrote
Hi, guys. Here is a demo program like this:
aa = 3
bb = 4
cc = 53
dd = 6
print cc
I put a breakpoint at the first line, then debug the program.
After 'aa' is set to '3', I modify '53' in the 3rd line to '34',
then
save the source file and run remain codes. As expected,
the output is '53'.
Correct because the interpreter and debugger are running
the original unmodified source file, it gets loaded into memory
when the interpreer started. To do what you want it would
have to read each line from the file as it went which would
be horrifically slow. It also would prevent the interpreter
compiling the code in memory which would add to the slowdown.
Does python has the ability to set cc to 34 after file
savings without restarting whole program?
No, and I don;t know of any language than can unless
you explicitly reload the code. But that is usually a
feature of the debugger/interpreter rather
than the language.
For example I worked ona C++ IDE a few years ago that
allowed you to change code and reload and continue running.
I've seen debuggers that let you step through code in
reverse. All very clever but nothing to do with the language.
And of course you could change the value of your variable
in the debugger by setting a breakpoint immediately after
the assignment. But that doesn't change the source code.
I heard LISP has this ability and wonder how could it
achieve this.
Lisp a a language does not, but some Lisp interpreters
or debuggers may well be able to reload a program in-flight.
It's not in the language it's in the tools.
HTH,
--
Alan Gauld
Author of the Learn to Program web site
http://www.alan-g.me.uk/
_______________________________________________
Tutor maillist - Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor