__author__="Sergio.Tapia"
__date__ ="$18-10-2010 12:03:29 PM$"
if __name__ == "__main__":
print("Hello")
print(__author__)
Where does it get __main__ and __name__?
Thanks for the help
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
The
__name__variable is made available by the runtime. It’s the name of the current module, the name under which it was imported."__main__"is a string. It’s not special, it’s just a string. It also happens to be the name of the main script when it is executed.The
if __name__ == "__main__":mechanism is the common way of doing something when a .py file is executed directly, but not when it is imported as a module.