You'll want to use the ipynb package/module importer. You'll need to install it: pip install ipynb
.
Create a Notebook named my_functions.ipynb
. Add a simple function to it.
def factorial(n):
if n == 0:
return 1
else:
return n * factorial(n-1)
Then, create a second IPython Notebook and import this function with:
from ipynb.fs.full.my_functions import factorial
Then you can use it as if it was in the same IPython Notebook:
testing = factorial(5)
See the documentation for more details.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…