[Tutor] Why use main() ?

Alan Gauld alan.gauld at yahoo.co.uk
Wed Jul 5 15:36:26 EDT 2017

On 05/07/17 16:37, David Rock wrote:

> This is a question about the benefits of using a main() function vs not.

Others have answered for the pros, but I confess that I don't
always use a main(), but only if all I'm doing is, say,
instantiating a class and running a method. For anything
more complex I'd write a main() (or test() or demo() ) to
go inside the
   if name==main

Alan G
Author of the Learn to Program web site
Follow my photo-blog on Flickr at:

More information about the Tutor mailing list