Skip to content

Is there any method to source some python code when press ! ? #580

Answered by asmeurer
Freed-Wu asked this question in Q&A
Discussion options

You must be logged in to vote

This can be done with a custom shell https://documen.tician.de/pudb/shells.html#custom-shells. Just exec the code you want into the _globals then pass it through to the existing shell function. For example, if you use the IPython shell:

from pudb.shell import run_ipython_shell

def custom_shell(_globals, _locals):
    exec('from matplotlib import pyplot as plt', _globals, _locals)
    return run_ipython_shell(_globals, _locals)

Replies: 2 comments 1 reply

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
1 reply
@cohml
Comment options

Answer selected by Freed-Wu
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
4 participants