Suppose I have two files. The first one contains all the functions I've written and which I usually import from my main file:
# my_functions.py
def sqrt_product(a, b):
from math import sqrt
return sqrt(a*b)
def create_df(lst):
from pandas import DataFrame as df
return df(lst)
and my main file:
# main.py
from my_functions import sqrt_product, create_df
print(sqrt_product(3, 3))
print(create_df([1, 2, 3])
Is there a more efficient way to import this function? Do I have to import every module for every function I create? WHat if I have several functions in the same file that relies on the same module?