Get Unlimited Contributor Access to the all ExamTopics Exams!
Take advantage of PDF Files for 1000+ Exams along with community discussions and pass IT Certification Exams Easily.
Answer is A. yes, and it can differentiate its behavior between the regular launch and import
Module have 2 users.One is the creator and other is the module users.The creator can execute his module and check the functionality using __name__ variable.Normal module users can execute the module by using import
In Python, when a module is run, the code in the module is executed. However, Python provides a built-in variable called __name__ that allows a module to determine whether it is being run as the main program or if it is being imported into another module.
This video also has a practical example of it around 10 minutes 30 seconds:
https://www.youtube.com/watch?v=jO6qQDNa2UY
He makes sure the function is only called when this file is the main file (i.e. not imported from somewhere else).
A voting comment increases the vote count for the chosen answer by one.
Upvoting a comment with a selected answer will also increase the vote count towards that answer by one.
So if you see a comment that you already agree with, you can upvote it instead of posting a new comment.
anjuvinayan
Highly Voted 4 years, 4 months agolocloc91
Highly Voted 4 years, 8 months agoFR99
3 years, 7 months agoTheFivePips
Most Recent 4 months, 2 weeks agoSoye_1001
1 year, 6 months agoSuvabrata
1 year, 10 months agomacxsz
1 year, 11 months agoAnton2020
2 years, 5 months agoPythonPuhal
3 years, 1 month agoSpectra
3 years, 7 months agoimsaad
3 years, 9 months agoSophieSu
4 years, 5 months agoFR99
3 years, 7 months ago