[Python-ideas] PEP for executing a module in a package containing relative imports

Greg Ewing greg.ewing at canterbury.ac.nz
Mon Apr 23 00:18:22 CEST 2007


Steven Bethard wrote:
> if there's nothing to be passed to the function, why make it a
> function at all?

I don't usually like to put big lumps of init code
at the module level, because it pollutes the module
namespace with local variables. So I typically end
up with

   def main():
     ...
     ...
     ...

   if __name__ == "__main__":
     main()

So I'd be quite happy if I could just define a
function called __main__() and be done with. I
don't understand why there's so much opposition
to that idea.

--
Greg



More information about the Python-ideas mailing list