Re:Show HN: A tool to convert Jupyter notebooks to beautiful...
by petters on Wednesday July 24, 2019 @01:43PM
(#20517635)
I have never understood why the "In[5]" and "Out[5]" in jupyter have to be so prominent, even in a output like this.
[ Parent
| on HN ]
Re:Show HN: A tool to convert Jupyter notebooks to beautiful...
by wodenokoto on Wednesday July 24, 2019 @06:34PM
(#20520690)
_5 is a magic variable with the value of the output from cell 5. _ refers to the last output. Super handy when working interactively.
Re:Show HN: A tool to convert Jupyter notebooks to beautiful...
by numlocked on Wednesday July 24, 2019 @07:27PM
(#20521155)
Oh my god. I have used Jupyter notebooks for 7 years and never knew this. I just had to fire one up to verify -- and yep; exactly as described. How amazing! Thank you!
Re:Show HN: A tool to convert Jupyter notebooks to beautiful...
by spondyl on Thursday July 25, 2019 @01:28AM
(#20522806)
I believe the _5 syntax is specific to Jupyter, but in Python, the output of the last statement you execute is bound to _
For example, if you simply enter 4 into a Python REPL, printing _ will also print 4
It's really handy if you call a long statement in the REPL and forget to save the output to a variable
I wrote about it once if you'd like to see some better examples: https://utf9k.net/blog/lost-python-results/
Re:Show HN: A tool to convert Jupyter notebooks to beautiful...
by petters on Thursday July 25, 2019 @05:48AM
(#20523990)
I knew this, which may be handy when developing (assigning variables is superior IMO though)
But in final output like this? I don't like it.
Re:Show HN: A tool to convert Jupyter notebooks to beautiful...
by wodenokoto on Friday July 26, 2019 @08:18AM
(#20534164)
No, you should not use output-references in code you share with people, but in my opinion it is one of the main reasons why jupyter notebooks in general put a large emphasis on displaying cell numbers
Re:Show HN: A tool to convert Jupyter notebooks to beautiful...
by ps101 on Thursday July 25, 2019 @01:54AM
(#20522910)
You just blew my mind.
Re:Show HN: A tool to convert Jupyter notebooks to beautiful...
by smcmurtry on Wednesday July 24, 2019 @05:37PM
(#20520050)
The numbers track the order that the cells were executed in. So, strictly speaking, you need the numbers to be able to reproduce the output of the notebook's author. However, I think it's bad practice and pretty uncommon to publish a notebook where you need to execute the cells out of order. So most of the time the numbers aren't useful.
Re:Show HN: A tool to convert Jupyter notebooks to beautiful...
by analog31 on Wednesday July 24, 2019 @07:17PM
(#20521080)
Indeed, and the line numbers are a warning that you might have an order-of-execution bug lurking somewhere.
Re:Show HN: A tool to convert Jupyter notebooks to beautiful...
by t1amat on Wednesday July 24, 2019 @02:34PM
(#20518193)
It seems useful to denote REPL input vs output, and to be able to identify output relating to input.
Re:Show HN: A tool to convert Jupyter notebooks to beautiful...
by petters on Wednesday July 24, 2019 @05:06PM
(#20519696)
Sure, but the [5] feels unnecessary in a finished document like this. I mean, the output should be right after the input anyway, right?
Re:Show HN: A tool to convert Jupyter notebooks to beautiful...
by mkl on Wednesday July 24, 2019 @05:29PM
(#20519945)
It's so it's easy to refer to things, like equation numbers in a maths book, or line numbers in code. E.g. people talking about someone's notebook here on HN can be specific and clear.
Re:Show HN: A tool to convert Jupyter notebooks to beautiful...
by lallysingh on Wednesday July 24, 2019 @05:37PM
(#20520051)
Agreed. They should be (5) Input: / Output:. Where input and output are on the same level of indentation under (5).
Re:Show HN: A tool to convert Jupyter notebooks to beautiful...
by hemanta212 on Wednesday July 24, 2019 @09:11PM
(#20521761)
People working with notebooks find it useful. You can remove it with one line of javascript though.