1. Home
  2. Computing & Technology
  3. Python

"Hello, World!" in Python With Tkinter

From , former About.com Guide

10 of 10

Calling main()

As usual, the main() function is the brains of the program. But it is worthless unless it is called. Here we call the main() function when the application is invoked directly:

if __name__ == "__main__":
     main()

By using this way of coding the program, the window is only created when the program is called directly. If, however, another Python program imports the file as a module, the program does not execute but stays secondary to the invoking application's processes. For more on __name__ and calling main(), see "What's in a Name?"

Explore Python
About.com Special Features

Holiday Central

What to eat, where to go, fun things to do and how to save money on the perfect gifts. More >

Family Tech Center

Stay connected and entertained with reviews on tips on the latest HDTVs, cellphones and more. More >

  1. Home
  2. Computing & Technology
  3. Python

©2009 About.com, a part of The New York Times Company.

All rights reserved.