if __name__ == "__main__" in python

In this code, I have explained about the basics of if name == main in python. I hope you will like the way I explained it. Make sure to add a comment and tell me if you like the code!

tut1a.py file as described iin the code

import os
def mostimpfunction():
    print("harry is a coder")

print(__name__)

def main():
    print(os.listdir("/"))
    print("Harry is great and he is the king of US")

if (__name__=="__main__"):
    main()

tut1b.py file as described in the code

import tut1a
tut1a.mostimpfunction()
tut1a.main()

Comments