How can you programmatically tell the CPython interpreter to enter interactive mode when done?
Question: If you invoke the cpython interpreter with the -i option, it will enter the
interactive mode upon completing any commands or scripts it has been given to
run. Is there a way, within a program to get the interpreter to do this even
when it has not been given -i? The obvious use case is in debugging by
interactively inspecting the state when an exceptional condition has occurred.


Answer: You want the [code module](http://docs.python.org/library/code.html).

    
    
    #!/usr/bin/env python
    
    import code    
    code.interact("Enter Here")
    

