Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

Creating a file for user defined functions using JupyterLab enviorment.

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?

click to hide/show revision 2
None

Creating a file for user defined functions using JupyterLab enviorment.

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?

click to hide/show revision 3
retagged

Creating a file for user defined functions using JupyterLab enviorment.

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?