Import functions from 'Home workspace files'

In order to reuse code accros notebooks it is easy to import code from python files. From the working directory it is easy to do so. However, if you want to share the code acros notebooks it gets difficult.

How can you import a python module from the ‘Home workspace files’?

Hello @botenvouwer,

It works just as you described: you can create a python module in the workspace files and it is ready to be imported in any notebook that has access to workspace files

So can you show how it looks in your environment? Currently I use something like:

import os
import sys
module_path = os.path.abspath(os.path.join('..'))
if module_path not in sys.path:
sys.path.append(module_path)

/data/notebook_files and /data/workspace_files are already in sys.path so the import works out of the box:

1 Like