[prev in list] [next in list] [prev in thread] [next in thread] 

List:       python-list
Subject:    Re: newbie question
From:       "Steven D'Aprano" <steve () REMOVE-THIS-cybersource ! com ! au>
Date:       2008-11-28 2:25:52
Message-ID: 013f4ea7$0$20626$c3e8da3 () news ! astraweb ! com
[Download RAW message or body]

On Thu, 27 Nov 2008 17:58:55 -0800, Asun Friere wrote:


> if __name__ == '__main__' :
>     import sys
>     sys.exit(main(sys.argv))
> 
> Doesn't this just pollute the namespace with main()?

Agreed. I don't see anything wrong with that. You have one function more 
than you otherwise would have had, and you get the benefit that after 
importing the module, you can say module.main(myargs) to run the code 
just as if you had run it from the command line.

In other words... in my opinion, writing a non-trivial main() function is 
the right thing to do.


-- 
Steven
--
http://mail.python.org/mailman/listinfo/python-list
[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic