how to call a function from another file?

You need to print the result of calling the function, rather than the function itself:

print pythonFunction.function()

Additionally, rather than import pythonFunction as pythonFunction, you can omit the as clause:

import pythonFunction

If it’s more convenient, you can also use from...import:

from pythonFunction import function
print function() # no need for pythonFunction.

Leave a Comment