If you want to use those variables in a separate module, you need to have the variables in the top level.
var1 = ....
var2 = ....
def main(x):
....
This is because variables inside a function are local to that function and only accessible in it.
If you want to only declare the variables in the top level but assign within the function-
var1 = None
var2 = None
def main(x):
global var1
global var2
# assign here
Remember however, variables assigned within a function will only reflect changes if that function is called. Importing a module will not automatically call the function, unless the function is called at the top level in the imported module-
var1 = None
var2 = None
def main(x):
global var1
global var2
# assign here
# x should be defined prior to this
main(x)