about main()

Abdur-Rahmaan Janhangeer arj.python at gmail.com
Thu Jul 5 06:39:07 EDT 2018

i once saw a python course (by academics) advertising main() in it's
promotional flier

that's put me in doubt as whether it's that recommended or not

Abdur-Rahmaan Janhangeer

>      main()
> >
> > is far is it good in py?
> >
> > or should file intended to be run just not include it?
> It's a matter of taste.  If your "file intended to be run" also contains
> things that might be useful as a module, use the "if __name__ ==
> '__main__'" trick.  Otherwise it can be more of a distraction than a
> help.  I'm not a big fan of "main()" functions myself; creating a
> function which will be called exactly once seems rather wasteful.
> --
> Rhodri James *-* Kynesim Ltd

More information about the Python-list mailing list