[Tutor] Why use main() ?
David Rock
david.rock at gmail.com
Wed Jul 5 11:37:10 EDT 2017
This is not a question about using if __name__ == '__main__':. I know
what the difference is between running the script or importing it and
using the value of __name__ to determine behavior.
This is a question about the benefits of using a main() function vs not.
ie,
if __name__ == '__main__':
#code goes here
vs
def main():
#code goes here
if __name__ == '__main__':
main()
I personally find using main() cumbersome, but many examples I come
across use main(). Is there some fundamental benefit to using main()
that I'm missing?
--
David Rock
david at graniteweb.com
More information about the Tutor
mailing list