Tuesday, February 19, 2019

python - How do I import package/module from a directory above

MyFolder/
function_folder/
__init__.py
function.py
def some_func():
return 'i am func'
creds.py
class creds(elf)
self.user=[]
self.pw=[]
test_folder/
test.py
prod_folder/
live.py

We're trying to organize the folders such that we separate a folder for python functions and testing scriopts and live scripts for automation.


How do you import function.py from live.py?


i've tried the following but none seem to work.


from .function import some_func
from ..function import some_func
from function_folder.function import *

I either get a ValueError:Attempted relative import beyond top-level package or function_folder is not a module

No comments:

Post a Comment

plot explanation - Why did Peaches' mom hang on the tree? - Movies & TV

In the middle of the movie Ice Age: Continental Drift Peaches' mom asked Peaches to go to sleep. Then, she hung on the tree. This parti...