You can’t use Python instead of logic blocks.
The python controller is a logic block. And that is the place where you can setup your Python code. (you still need place the code in a text file with any text editor )
The Python controller works like all the other controllers.
With one exception:
- it can perform tasks that actuators should do (therefore there is no Python actuator)
So read on how sensors, controllers and actuators do and how they do it. I think you find some good information at Blender.org.
- when a sensor triggers the controller it interpretes and executes the textfile with the name you entered in the Script field
- when a sensor triggers the controller
- the first execution: it loads and initializes the module which name is entered at the Module field (can by an external .py file)
- each execution: calls the function that you entered after the module name in the Module field (separated by a ‘.’)
- you define the function in you module.
- the function gets one argument: the current controller executing the function
- the module remains in memory after executing the controller
I hope it helps