Access several functions from a file using parent directory

37 views Asked by At

Say I have a folder Dir with several files Funs_1, Funs_2 each of which contain several functions with unique names. Structure is as such:

project
│   foo.py
└───Dir
       Funs_1 >> some_function_1
       Funs_2 >> some_function_2

How can I call some_function_1 and some_function_2 from the project file foo.py using Dir.Funs_1.some_function_1 or something of that nature?

1

There are 1 answers

0
Ajax1234 On BEST ANSWER

In your case you can simply import the file from the directory and then access the functions:

from Dir import Funs_1, Funs_2
Funs_1.some_function_1()
Funs_2.some_function_2()

Alternatively:

import Dir.Funs_1, Dir.Funs_2
Dir.Funs_1.some_function_1()
Dir.Funs_2.some_function_2()