I have a Python function in a file called func.py
def calc(x,y):
return x*y
I have to import this function while working in another file called mytask.py
How can I import the function?
I have a Python function in a file called func.py
def calc(x,y):
return x*y
I have to import this function while working in another file called mytask.py
How can I import the function?
Save the file in the same directory and then have a statement
from func import calc
To import from a different directory
__init__.py
and have a line __all__ = ['calc']
from funcs import func
Reference