[Resending because I messed up on last email] My question was regarding a piece of boilerplate code:
if __name__ == '__main__': main() This calls the main function, but I don't understand what the 'if' statement is doing here. In the simple programs that I've seen this so far, there is no variable called "_name_", and even if there was, why is it comparing it to "_main_"? Why can't the main function just be called by typing main()- why do we need this if statement to precede it? Thanks. -Alex On Thu, Jun 14, 2012 at 3:17 PM, Alexander Quest <alexxqu...@gmail.com>wrote: > Got it Dave- sorry about not sending it to the newsgroup as well. > > My question was regarding a piece of boilerplate code: > > > if __name__ == '__main__': > main() > > This calls the main function, but I don't understand what the 'if' > statement is doing here. In the simple programs that I've seen this so far, > there is no variable called "_name_", and even if there was, why is it > comparing it to "_main_"? Why can't the main function just be called by > typing main()- why do we need this if statement to precede it? Thanks. > > -Alex > > On Thu, Jun 7, 2012 at 6:16 PM, Dave Angel <d...@davea.name> wrote: > >> On 06/07/2012 02:36 PM, Alexander Quest wrote: >> > Ok, thanks guys. I also had one more quick question regarding a piece of >> > boilerplate code: >> > >> >> To get a response, you will needs to leave your question at the python >> tutor newsgroup. We are part of a group, not offering private advice. >> >> Normally, you just do a Reply-all to one of the existing messages on the >> thread, to include the group. But you can also type tutor@python.org >> as a CC: >> >> I've been volunteering my time on various forums for over 25 years now, >> so I think I speak for lots of other volunteers. >> >> >> -- >> >> DaveA >> > >
_______________________________________________ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor