Yaakov Bressler
Yaakov Bressler

Reputation: 12018

Access several functions from a file using parent directory

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?

Upvotes: 0

Views: 29

Answers (1)

Ajax1234
Ajax1234

Reputation: 71451

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()

Upvotes: 1

Related Questions