I want to write a python program. My code looks like this
if __name__ == "__main__":
   a,b = ParseArgs() # this is my function which uses argparse lib
   n = 30
   x = np.random.randint(20)
   do_sth(a,b) # this function uses n and x inside its definition
I'm wondering if I could do sth like this:
def setup():
    a,b = ParseArgs() # this is my function which uses argparse lib
    n = 30
    x = np.random.randint(20)
if __name__ == "__main__":
   setup()
   do_sth(a,b) # this function uses n and x inside its definition
so that code looks more clear (note that in my real code setup part is much longer). I suppose that I can't do it, first of all because do_sth uses x and n. But what if I just change do_sth so that it takes x and n as arguments? Would it then be a good idea to put lines that create some global variables in setup function?
