These docs explain:
Script Mode
In Script mode, the controller is linked to a script, the whole script
will be executed before the logic moves on. Everything in the script
will happen at the same frame, if the same value or attribute are
changed more than once, only the latest will be visible in the game
because of this. If for example the position of an object is changed
first to (100.0,100.0,100.0) but later in the same script changed to
(0.0,0.0,0.0), then only the (0.0,0.0,0.0) will be visible to the
player because the move to (100.0,100.0,100.0) happened on at the same
frame.
Module Mode
Since Blender 2.49 the Python module controller was added. Simply
choose Module instead of Script on your Python controller drop-down
menu. Then you define a function on that module and call that function
from the controller. Instead of writing “myScript.py” on the script
edit box, you’ll write “myModule.myFunc” on the module edit box. This
function will run every time the controller is called. But other
functions and variables outside of myFunc’s scope will only run once.
This is good for optimizing your code when you want to initiate
variables only once then use them later.
The Python module controller supports any number of attributes, this
means packages are supported automatically. As well as
“myModule.myFunc” you can do “myPackage.myModule.myFunc”, nested
packages work too, as does method calls on class instances like:
“myPackage.myModule.myInstance.myMethod”. The python controller is
passed to the python function as an argument for functions that take
one arg.
Regrettably the 2.6x docs miss this info.