[prev in list] [next in list] [prev in thread] [next in thread]
List: python-list
Subject: Re: newbie question
From: Asun Friere <afriere () yahoo ! co ! uk>
Date: 2008-11-28 1:58:55
Message-ID: 936fb8cc-5b9a-4887-b781-18175eb34251 () c36g2000prc ! googlegroups ! com
[Download RAW message or body]
On Nov 27, 9:05 pm, Bruno Desthuilliers <bruno.
42.desthuilli...@websiteburo.invalid> wrote:
> The problem is that you often have more to do in the __main__ section of
> a script than just calling one simple function, and you don't
> necessarily want to pollute the module's namespace with all this code.
As I said, it's probably just me ;) I'm not sure I understand,
however, why calling multiple functions under 'if __name__ ...' will
pollute the namespace if these functions are already defined there?
Eg.
def foo (arg) :
#stuff
return exit_status
def bar (arg) :
#stuff
return exit_status
def main (argv) :
#parse args
#call and do stuff with foo and bar
return exit_status
if __name__ == '__main__' :
import sys
sys.exit(main(sys.argv))
Doesn't this just pollute the namespace with main()?
Surely you should be structuring the code above the test to minimise
namespace pollution.
--
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