obsidian-execute-code
obsidian-execute-code copied to clipboard
None after each line in notebook mode
Hi, thanks for making this extension. It is making learning to code and documenting my process so much more enjoyable.
Is there a reason why "none" is printed after everything though? Or maybe I'm just doing something wrong and this isn't an issue/bug?
Also this seems to only happen in notebook mode
Sorry if this is annoying... such a small issue compared to the others that've been logged lol
Hey, don't worry, that's normal. The notebook mode is based on the python interpreter you can use in the command line. If you enter python
(or python3
) on the command line, you can execute your code line-by-line or in snippets. We handle each code box as a snippet that is executed in the interpreter.
If you call a function in the interpreter, than the return value is printed in the console. E.g., paste the following line into the interpreter and in prints 6
to the console:
import math
math.factorial(3)
But if a python function does not return a object or number, then it returns None
. That means if you call a function without a return value (e.g. the function below), then the interpreter returns None
. At the moment, we add the None to the output of the code block. We could change this in future releases.
def f():
pass
Until then, you can ignore the None.