How can I use "if __name__ == '__main__':" in my code below?

There are more clever ways of doing it, but if you just want to get it working, you can try wrapping your entire script as a giant function:


from scipy import stats, optimize
# other imports

def giant_function():
    #Load the Data

    # model data and sample

    # plot results

if __name__ == '__main__':
    giant_function()
1 Like