Report this

What is the reason for this report?

How to import a python function that's outside of packages/xx/yy?

Posted on October 6, 2022

Hello,

Based on the jokes python example, I’d like to import code that sits at the root of the repository.

So, something along those lines:

# test.py

def test():
    return {"test": "test"}


# packages/joke/joke/__main__.py

import pyjokes
from ....test import test # this won't work?


def main(args):
    joke = pyjokes.get_joke()
    return {
        'body': {
            'response_type': 'in_channel',
            'text': joke
        }
    }

How do I import any code that I have in a level above the current packages/joke/joke folder structure? - Say I have code to share between more than one package?

The developer cloud

Scale up as you grow — whether you're running one virtual machine or ten thousand.

Start building today

From GPU-powered inference and Kubernetes to managed databases and storage, get everything you need to build, scale, and deploy intelligent applications.