9gager 9gager - 3 months ago 7
Python Question

Import function from a file in root directory

My file where I am working is at :

folder/src/views/basics.py
.

I want to import function in file where is present at :
folder/src/server.py
.

How to import function from server.py to basics.py ?
Note: I have made a __ init __.py file in
folder/src/
and
folder/src/views

Answer
from ..server import Function
Function()

or

from .. import server
server.Function()