I was referring to this question to call a Python function from another Python file.
So I have 2 Python scripts in the same folder: myFunc.py
and caller.py
.
First, I defined a simple function in myFunc.py
as following:
def mySqrt(x):
return x**2
...then I tried to use this function in my caller.py
, like this:
import myFunc as mySqrt
a = mySqrt(2)
print(a)
...but it returns:
'module' object is not callable
...when the script caller.py
is executed.
What did I do wrong here?