Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Automatic console output #1

Closed
sbliven opened this issue Apr 20, 2020 · 4 comments · Fixed by #15
Closed

Automatic console output #1

sbliven opened this issue Apr 20, 2020 · 4 comments · Fixed by #15
Assignees

Comments

@sbliven
Copy link

sbliven commented Apr 20, 2020

It would be great if space cells would automatically print their return result similar to a normal cell. Having to use the print statement for output is cumbersome.

@sbliven
Copy link
Author

sbliven commented Apr 20, 2020

I looked into this a little and wanted to share my progress. Cell outputs can be assigned by calling

self.shell.displayhook(value)

within SpaceMagick.space.

However, it seems a bit tricky to get the return value of executing a cell. Right now we're just using exec, which does not keep this. The ipython run_cell mechanism is doing full AST parsing to get it.

@davidesarra
Copy link
Owner

Hi @sbliven! Thanks for opening this issue and sorry for my delayed reply. I agree. I'd be nice to display the return values of the cells.

We can’t use IPython parsing methods because we need to control the local namespace. However, we can achieve this by letting Jupyter Spaces parse the cell and modify the resulting syntax tree before compiling and executing it.

Later this week I’ll open a PR to improve this behaviour so that it matches what one would expect from IPython.

@davidesarra davidesarra self-assigned this Jun 17, 2020
@davidesarra
Copy link
Owner

I looked more into alternative ways to achieve a "console output" behaviour that matches IPython's. I think we actually can rely on IPython's parsing methods whilst temporarily replacing the IPython user namespace. In this way we can achive virtually perfect feature parity with IPython console outputs (e.g. also tracebacks).

@davidesarra
Copy link
Owner

I'll probably stick with executing the cell interactively (to autmaticaly return the output) without using IPython's shell. I'm not delivering this yet cause I'd like to see if there a solution to address it alongside #2.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants