When running code in a Jupyter kernel it is possible to get the iopub or the shell messages from the respective channels. Is is possible to extract the raw python objects from the kernel as well?
Say for the below code
code = """a = {'a': 1}
b = {'b': 2}
"""
class Shell:
def __init__(self):
km = KernelManager()
km.start_kernel()
client = km.client()
client.start_channels()
client.execute(code)
print(client.get_iopub_msg())
print(client.get_shell_msg())
I want to retrieve the actual objects a and b so that they can be used in the current python application. Is that possible?