https://online.codingblocks.com/app/player/209779/content/201870/8816/lecture
at 8:29 in his video why does it print “main” for math/simple.py
doesnt the __ name __ variable print the name of the module hence simple should be printed instead of main
Modules doubt regarding __name__ variable
Hey @devchopra999_11c6416ab7f09bbf,
__name__
is a special variable which works as if the source file is executed as the main program, the interpreter sets the __name__
variable to have a value __main__
. If this file is being imported from another module, __name__
will be set to the module’s name.
I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.
On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.