[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.lang.python

Edit and continue for debugging?

Bronner, Gregory

3/7/2008 2:45:00 PM


I haven't seen much on this for a few years:

I'm working on a GUI application that has lots of callbacks. Testing it
is very slow and quite boring, as every time I find an error, I have to
exit it, restart it, and repeat the series of clicks. It would be really
amazing if python supported a reasonable form of edit and continue.

Is there any way to do this? I'd like to be able to change my code and
have it apply to a running instance of a class. I wonder if it would be
possible to do this by configuring the interpreter to parse classes and
functions rather than whole modules, and to re-parse as necessary; also
to have byte-compiled modules be singletons rather than be standard
reference counted objects.






Thanks
Gregory R. Bronner
(212) 526-0102
gregory.bronner@lehman.com
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

This message is intended only for the personal and confidential use of the designated recipient(s) named above. If you are not the intended recipient of this message you are hereby notified that any review, dissemination, distribution or copying of this message is strictly prohibited. This communication is for information purposes only and should not be regarded as an offer to sell or as a solicitation of an offer to buy any financial product, an official confirmation of any transaction, or as an official statement of Lehman Brothers. Email transmission cannot be guaranteed to be secure or error-free. Therefore, we do not represent that this information is complete or accurate and it should not be relied upon as such. All information is subject to change without notice.

--------
IRS Circular 230 Disclosure:
Please be advised that any discussion of U.S. tax matters contained within this communication (including any attachments) is not intended or written to be used and cannot be used for the purpose of (i) avoiding U.S. tax related penalties or (ii) promoting, marketing or recommending to another party any transaction or matter addressed herein.
2 Answers

Jonathan Gardner

3/8/2008 12:31:00 AM

0

This is an interesting issue because we who write web applications
face the same problem. Except in the web world, the application state
is stored in the browser so we don't have to work our way back to
where we were. We just keep our url, cookies, and request parameters
handy.

Before I go on, I would suggest one thing: unit tests. If you have a
hard time writing unit tests, then you need to rethink your code so
that you can write unit tests. Having unit tests, running them, and
debugging them is a far easier way to catch bugs and prevent them from
coming back. If you don't know what a "regression test" is, you should
look into the field of software testing. You'll thank yourself for it.

I'm no lisp programmer, but my understanding of how lisp and lisp-like
programs do this is that they replace the function with the new
version. What this does to threads that are already running the
function, I guess they just finish and continue on. What about
closures? Well, you're out of luck there. I guess lisp programmers
don't use closures in that way too often.

I guess you could do the same in your debug session, although it would
be hacky and difficult at best. You're out of luck if there's more
than a handful of things referring to the object.

A better solution would probably be to fix the offending line in the
offending file and somehow magically reload that file. Well, you still
have the same problem. See, a lot of your program depends on the
functions and classes and objects already in that file. Those
dependencies don't get magically fixed to point to the new objects
just loaded. You'll have to go throughout the entire universe of
variables and make them point to the new stuff. This is not an easy
feat to do.

In the end, you're going to realize that unless you design the system
to allow you to "reload" files, whatever that means (and you'll have
to define that as well), you aren't going to be able to do that. There
just isn't a straightforwad, one-size-fits-all solution to this
problem, except for stopping the process altogether and restarting
from scratch.

On Mar 7, 6:44 am, "Bronner, Gregory" <gregory.bron...@lehman.com>
wrote:
> I haven't seen much on this for a few years:
>
> I'm working on a GUI application that has lots of callbacks. Testing it
> is very slow and quite boring, as every time I find an error, I have to
> exit it, restart it, and repeat the series of clicks. It would be really
> amazing if python supported a reasonable form of edit and continue.
>
> Is there any way to do this? I'd like to be able to change my code and
> have it apply to a running instance of a class. I wonder if it would be
> possible to do this by configuring the interpreter to parse classes and
> functions rather than whole modules, and to re-parse as necessary; also
> to have byte-compiled modules be singletons rather than be standard
> reference counted objects.

Bernard

3/8/2008 1:27:00 AM

0

As Jonathan says. :)

I had a lot of fun learning how to plug doctests[1] into my python web
apps and now I'm just adding them automatically as I create classes
and functions. Those tests tidbits says so much more than a paragraph
of comments.

[1] : http://docs.python.org/lib/module-do...

On 7 mar, 09:44, "Bronner, Gregory" <gregory.bron...@lehman.com>
wrote:
> I haven't seen much on this for a few years:
>
> I'm working on a GUI application that has lots of callbacks. Testing it
> is very slow and quite boring, as every time I find an error, I have to
> exit it, restart it, and repeat the series of clicks. It would be really
> amazing if python supported a reasonable form of edit and continue.
>
> Is there any way to do this? I'd like to be able to change my code and
> have it apply to a running instance of a class. I wonder if it would be
> possible to do this by configuring the interpreter to parse classes and
> functions rather than whole modules, and to re-parse as necessary; also
> to have byte-compiled modules be singletons rather than be standard
> reference counted objects.
>
> Thanks
> Gregory R. Bronner
> (212) 526-0102
> gregory.bron...@lehman.com
> - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
>
> This message is intended only for the personal and confidential use of the designated recipient(s) named above. If you are not the intended recipient of this message you are hereby notified that any review, dissemination, distribution or copying of this message is strictly prohibited. This communication is for information purposes only and should not be regarded as an offer to sell or as a solicitation of an offer to buy any financial product, an official confirmation of any transaction, or as an official statement of Lehman Brothers. Email transmission cannot be guaranteed to be secure or error-free. Therefore, we do not represent that this information is complete or accurate and it should not be relied upon as such. All information is subject to change without notice.
>
> --------
> IRS Circular 230 Disclosure:
> Please be advised that any discussion of U.S. tax matters contained within this communication (including any attachments) is not intended or written to be used and cannot be used for the purpose of (i) avoiding U.S. tax related penalties or (ii) promoting, marketing or recommending to another party any transaction or matter addressed herein.