n-riesco / ijavascript

IJavascript is a javascript kernel for the Jupyter notebook
Other
2.18k stars 187 forks source link

How does output work? #63

Closed neil-s closed 8 years ago

neil-s commented 8 years ago

If I understand correctly, is this the way output works:

1) If the code in the cell write something to stdout or stderr, show that. 2) If not, then print the output of the last statement in the cell.

If so, how can I go about suppressing (2) at all times? The one example I've seen in the usage notes is simply ending blocks with an extra line containing an empty string, but that seems inelegant.

(I'm on v5.0.10 right now, on Ubuntu 14.04.3 LTS, if that matters)

n-riesco commented 8 years ago

1) If the code in the cell write something to stdout or stderr, show that.

It's a bit more complicated. Cells in a notebook can show three types of output:

In some cases the result of evaluating the code is not shown, e.g.:

IJavascript provides a flag to enable similar behaviour:

ijs --ijs-hide-undefined

To disable the output completely, in v5.0.10, you could define your own $$mimer$$:

$$mimer$$ = function() { return {} };

If you don't want to include this code in your notebooks, IJavascript also offers a flag to run a script on startup:

ijs --ijs-startup-script=path/to/script.js

This solution is not ideal for your needs, because it causes the notebook to show an empty line with the label Out[n]:. For this reason, I think it's better if I added another flag:

ijs --ijs-hide-execute-result

Also note that I'm deprecating the use of $$mimer$$. See issue #59 .


IJavascript v5.0.10 is affected by issue #58 . If you plan to produce asynchronous output or use the notebook option, Run all, then I would advise to update your installation (the latest version is 5.0.11-beta.0).

neil-s commented 8 years ago

Thanks @n-riesco , no wonder I was able to infer what output to expect based on code, it's not a simple mechanism until explained, but makes a lot of sense now. I think the ijs-hide-undefined flag was what I needed. Updated to the latest version on npm, but I'm not sure how the previous version had got on my system because neither apt nor npm had it in the list of installed packages.