All code in a python script or module (which is basically the same thing - the difference being how it is used) is "operational code" one way or another. The clean way to structure a script's code is to have everything in functions - what you name "operational code" being in a "main()" function - and just have a call to that "main" function if the module is used as a script, ie:
# mymoduleorscript.py
import something
from somewhere import somethingelse
def somefunc(arg1, arg2):
# ...
def otherfunc(arga, argb):
# ...
def main(*args):
# "operational" code here
return status_code # 0 if ok, anything else if error
# only call main if used as a script
if __name__ == "__main__":
import sys
sys.exit(main(*sys.argv[1:]))
Note that this is not a "in my opinion" answer, but the officially blessed OneTrueWay of doing things.