The easiest way to call a function from another file is by using import. In the current example, both files are in the same directory.

The content of the runnable file.

from another_file import function_from_another_file


The content of the file with the function used for import:

def function_from_another_file(name):
    print(f"Hello, {name}, from another file!")


Hello, Batman, from another file!