How to link multiple scripts?

You can import any Python file simply by typing:

import filename

But in this case you have to type the file name each time you want to use it. For example, you have to use filename.foo to use the specific function foo inside that file. However, you can also do the following:

from function import *

In this case all you have to do is to directly type your commands without filename.

A clear example:

If you are working with the Python turtle by using import turtle then each time you have to type turtle.foo. For example: turtle.forward(90), turtle.left(90), turtle.up().

But if you use from turtle import * then you can do the same commands without turtle. For example: forward(90), left(90), up().


At the beginning of driver.py, write:

import functions

This gives you access to attributes defined in functions.py, referenced like so:

functions.foo
functions.bar(args)
...

You can import modules. Simply create different python files and import them at the start of your script.

For example I got this function.py file :

def func(a, b):
    return a+b

And this main.py file:

import function

if __name__ == "__main__":
    ans = function.func(2, 3)
    print(ans)

And that is it! This is the official tutorial on importing modules.