I have a program that runs when the functions have not been defined. When I put code into a function, it does not execute the code it contains. Why? Some of the code is:
def new_directory():
if not os.path.exists(current_sandbox):
os.mkdir(current_sandbox)
Problem 1 is that you define a function (“def” is an abbreviation of “define”), but you don’t call it.
Problem 2 (which hasn’t hit you yet) is that you are using a global (
current_sandbox) when you should use an argument — in the latter case your function will be generally useful and even usefully callable from another module. Problem 3 is irregular indentation — using an indent of 1 will cause anybody who has to read your code (including yourself) to go nuts. Stick to 4 and use spaces, not tabs.