librelist archives

« back to archive

Debugging tip

Debugging tip

From:
Jonas Galvez
Date:
2010-11-11 @ 10:14
You can place

...
import code
code.interact(local=(locals().update(globals()), locals())[1])
...

anywhere in your handler function and it will halt execution and give
you an interactive shell right within at the Flask development
server's log window (with all current globals and locals available).

-- Jonas

Re: Debugging tip

From:
Jonas Galvez
Date:
2010-11-11 @ 10:16
Just realized that with that I may overwrite local variables with global ones.

Unlikely scenario, but to prevent:

...
import code
code.interact(local=(globals().update(locals()), globals())[1])
...

-- Jonas