OSDir


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

about main()


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
https://github.com/Abdur-rahmaanJ

>      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
>