Most scripts look something like the following:
import module1
import module2
CONSTANT=...
def foo():
...
def bar():
....
class Baz():
....
def run(verbose=False):
....
if __name__=='__main__':
import optparse
def parse_options():
usage = 'usage: %prog [options]'
parser = optparse.OptionParser(usage=usage)
parser.add_option('-v', '--verbose', dest='verbose',
action='store_true',
default=False,
help="verbose")
return parser.parse_args()
def cli():
opt,args=parse_options()
run(verbose=opt.verbose)
cli()
So the body of your script is mainly composed of function/class definitions. There (usually) is very little code that isn't inside a function/class definition.
I would try to group the functions in whatever way facilitates organization and readability. If you believe a function can be reused in places other than that particular script, then place it in a module, and import that module into this script.
Define PYTHONPATH and PATH in your crontab. Then you should have no problem running your script from cron.