Thursday, April 5, 2012

Equivalent of IDL's "stop" command?

import sys
print "hello world"
sys.exit()
print "this does not print"

2 comments:

  1. sys.exit() is more like IDL's return. The closest equivalent I can identify is "import pdb; pdb.set_trace()" (which is also similar to IDL's breakpoint command). However, unlike IDL, if you break out of code with set_trace(), you cannot continue from that point (as far as I know).

    ReplyDelete
  2. You can break out with `IPython.embed`, and it will continue from the point after you exit the interactive mode. See http://stackoverflow.com/a/43270081

    ReplyDelete