[Python-ideas] Replacing the if __name__ == "__main__" idiom (was Re: making a module callable)
Georg Brandl
g.brandl at gmx.net
Sun Nov 24 18:09:28 CET 2013
On 11/24/2013 05:26 PM, Philipp A. wrote:
> i’m all for a special method name or decorator, because of the namespace issue.
>
> once you do more on your main function than print(‘Hello World’), say define
> variables, you tend to do:
>
> |
> def main():
> ...
>
> if __name__ == '__main__':
> main()|
>
> in order not to pollute the namespace of the module.
I don't get that argument: when the module is executed as the main script, you
shouldn't need to care about the "module namespace" since it isn't really one.
Georg
More information about the Python-ideas
mailing list