[Tutor] Why use main() ?

David Rock david at graniteweb.com
Wed Jul 5 18:54:05 EDT 2017

* Mats Wichmann <mats at wichmann.us> [2017-07-05 16:47]:
> > 
> As a vaguely contradictory position to a part of this (which I in the
> main agree with): if your objective is to make a module, and also have
> some code (perhaps including test code) which is run in the non-module
> (aka not-imported) case, then stuffing that code in a function main()
> means you've exposed that not-really-module-code as part of the module,
> and might then want to take steps to hide it from clients so it doesn't
> end up looking like part of the module API.

In most cases, my scripts tend to be pretty self-contained and written
for my own purposes, so that would rarely be an issue.  

How would you hide main() if you _were_ concerned about it?

David Rock
david at graniteweb.com

More information about the Tutor mailing list