0

ys it possible to invoke the keyboard in a python script? E.g. in MATLAB there is way to write

% A lot of code "A"
...
keyboard
% A lot of code "B"
...

in a script, so if you execute the script, it will halt at "keyboard" and you can go on in your MATLAB-shell with the workspace which was build up by code in "A". Is there a similar command in Python?

0

1 Answer 1

2

Take a look at the Python debugger; instead of keyboard you'd use:

import pdb; pdb.set_trace()

and the debugger stops execution and lets you investigate the state of your program.

Sign up to request clarification or add additional context in comments.

2 Comments

If you use ipython, there's also ipdb which runs pdb in the ipython interface. Similar invocation as well import ipdb; ipdb.set_trace(). It's a separate package tho, available in PyPI.
Nice, it is excactly what i was looking for

Your Answer

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

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.