0
votes

I have the following folder structure:

Python_Game/src/domain/boards.py
Python_Game/tests/test.py

I'm trying to import function boards.py to test.py.

I've tried:

import sys
sys.path.append('../src')
import domain
from domain import boards

and a lot of other attempts (including tipps in StackOverflow too) but so far I couldn't manage to import properly . Please give me some piece of advice.

I am working with Python 3.7.4, domain and tests folders contains __init__.py file.

2
Have you tried using import ..src.domain.boards?ICanKindOfCode

2 Answers

0
votes

From your src directory :

import domain.boards as boards

From your Python_Game directory:

import src.domain.boards as boards

And follow the same logic for tests

0
votes

To access boards from tests:

import sys
#use full path for your boards file; if you are on windows replace / with \\
sys.path.append('Python_Game/src/domain/boards.py')

#import entire module:
import boards as boards

#or import specific functions/variables
from boards import function_name