Well, what you can do is to create a "header" file if your file is app.py you can create a functions_app.py (put all your functions here) and in app.py you will do a from functions_app import * and then you can use all functions you want in any order without having to worry about where they are declared. This way you can have a file with setup variables at the beginning of the script which is I GUESS what you want. I do this too.