2

The title might be slightly confusing. What I mean is this. Let's say I have a code block which has some error checking code. If there is an error, the (tangled) program should not continue past that point. Let's say I work with python. If I have a source code like this

if len(dummy_list) == 0:
  print("Error!!!")
  sys.exit(0)

Executing this in a code block makes EMACS hang. So I don't want this line to be executed in my source block. But I want this line to be present in the tangled source code. Moreover, it would be great if there was a way to destroy the current running session when I counter an error. Is there a way to achieve this?

1
  • Can you please post a new question about destroying the current session when encountering an error?
    – gregoryg
    Aug 15, 2020 at 18:41

1 Answer 1

2

You can set the error checking code in a separate code block with headers set to something like

:tangle myfile.py :eval never

This works because code blocks with the same :tangle path are concatenated sequentially into the resulting file. If you are running your Python code in python or ipython sessions then the evaluations should work even though they are in multiple code blocks.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.