Is there a shorter form of this?
if __name__ == '__main__':
It is pretty tedious to write, and also doesn’t look very nice in my opinion 🙂
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.
PEP299 proposed a solution to this wart, namely having a special function name
__main__. It was rejected, partly because:http://www.python.org/dev/peps/pep-0299/
So the ugliness will stay, at least as long as Guido’s the BDFL.