NameError: name 'main' is not defined

Robert Kern robert.kern at gmail.com
Tue Dec 18 23:11:03 EST 2007


jolly wrote:
> hey guys,
> 
> When i try to run my code I get an error. NameError name 'main is not
> defined'
> 
> [code]
> if __name__ == "__main__":
>     main()

Put this at the end of the file. Currently, it is getting executed before the
code that defines main().

-- 
Robert Kern

"I have come to believe that the whole world is an enigma, a harmless enigma
 that is made terrible by our own mad attempt to interpret it as though it had
 an underlying truth."
  -- Umberto Eco




More information about the Python-list mailing list