as these two examples illustrateall module-level code is executed immediately at the time it is imported howeverif it is inside method or functionthe function will be createdbut its internal code will not be executed until the function is called this can be tricky thing for scripts (such as the main script in our -commerce examplethat perform execution oftenwe will write program that does something usefuland then later find that we want to import function or class from that module in different program howeveras soon as we import itany code at the module level is immediately executed if we are not carefulwe can end up running the first program when we really only meant to access couple functions inside that module to solve thiswe should always put our startup code in function (conventionallycalled mainand only execute that function when we know we are running the module as scriptbut not when our code is being imported from different script but how do we know thisclass usefulclass'''this class might be useful to other modules ''pass def main()'''creates useful class and does something with it for our module ''useful usefulclass(print(usefulif __name__ ="__main__"main(every module has __name__ special variable (rememberpython uses double underscores for special variablessuch as class' __init__ methodthat specifies the name of the module when it was imported when the module is executed directly with python module pyit is never importedso the __name__ is arbitrarily set to the string "__main__make it policy to wrap all your scripts in an if __name__ ="__main__"testjust in case you write function you will find useful to be imported by other code someday somethods go in classeswhich go in moduleswhich go in packages is that all there is to it