Ask Your Question

Oshio's profile - activity

2021-01-27 13:19:04 +0200 received badge  Student (source)
2020-11-03 19:14:13 +0200 asked a question Creating a file for user defined functions using JupyterLab environment.

I want to create a function in a separate file, and use that function in another one. Here is the example:

#my_file.ipynb

def my_function(n):
    return n*2

#main.ipnyb

attach('my_file.ipynb')
my_function(2)

But when doing this at the JupyterLab I receive the following erros:

(1) ValueError: unknown file extension '.ipynb' for load or attach (supported extensions: .py, .pyx, .sage, .spyx, .f, .f90, .m)

(2) NameError: name 'my_function' is not defined

This method seems to work for .sage files, but is not working for '.ipynb'.

There is some way to accomplish the result demonstrated through my example using only JupyterLab environment?