[Chicago] __name__ == "__main__"

Michael Tobis mtobis at gmail.com
Fri Oct 26 17:46:06 CEST 2007

I agree with everything Kumar says. It could be prettier, but it's
extremely useful to put the
__name__ == "__main__" around code in your file that doesn't define
objects or functions.

Now that it's come up, though. what I never quite understood was the
extra level of indirection that many people including Guido favor.

def invoke_lots_of_stuff():
   print "I represent a lot of very clever objects and functions"

def main():

if __name__ == "__main__":

What's the purpose of the extra layer provided by the main() function?

Also, yeah, there's a little bit of a Python activity in Chicago...
(Miss y'all; looking forward to seeing you again in March.)


More information about the Chicago mailing list