Path: csiph.com!x330-a1.tempe.blueboxinc.net!usenet.pasdenom.info!aioe.org!news.stack.nl!newsfeed.xs4all.nl!newsfeed6.news.xs4all.nl!xs4all!post.news.xs4all.nl!not-for-mail Return-Path: X-Original-To: python-list@python.org Delivered-To: python-list@mail.python.org X-Spam-Status: OK 0.047 X-Spam-Evidence: '*H*': 0.91; '*S*': 0.00; 'parser': 0.05; 'disable': 0.09; 'received:10.50': 0.09; 'received:209.85.214.174': 0.13; 'to:name:python-list@python.org': 0.15; 'temp': 0.16; "doesn't": 0.22; 'command': 0.24; 'code': 0.26; 'variable': 0.28; "i'm": 0.28; "skip:' 10": 0.29; 'skip:p 30': 0.29; 'servers.': 0.30; 'sub': 0.30; 'pretty': 0.31; 'message-id:@gmail.com': 0.31; 'like.': 0.32; 'too': 0.33; 'certain': 0.34; 'to:addr:python- list': 0.35; 'apply': 0.35; 'subject:How': 0.35; 'received:209.85.214': 0.36; 'checks': 0.37; 'run': 0.37; 'charset :us-ascii': 0.37; 'received:google.com': 0.37; 'using': 0.37; 'received:209.85': 0.38; 'bunch': 0.38; 'subject:from': 0.39; 'received:209': 0.39; 'to:addr:python.org': 0.40; 'header:Received:6': 0.61; 'header:Message-Id:1': 0.62; 'iphone': 0.68; 'subject:handle': 0.84 Received-SPF: pass (google.com: domain of rodrick.brown@gmail.com designates 10.50.87.136 as permitted sender) client-ip=10.50.87.136; Authentication-Results: mr.google.com; spf=pass (google.com: domain of rodrick.brown@gmail.com designates 10.50.87.136 as permitted sender) smtp.mail=rodrick.brown@gmail.com; dkim=pass header.i=rodrick.brown@gmail.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=subject:from:content-type:x-mailer:message-id:date:to :content-transfer-encoding:mime-version; bh=YTIpvHN03/0qkXBXv0kOMvcpeGdfwnMpIXBexVxBElE=; b=ffLx6LgDLVe3rcxG7/hmlhB02Mwrgb6b54ClySxS/+bczIfhN0Cfm7WTpXv0nBdhnN lk1nG4mcBPfRlsUvwkXUVCcx/bx3IwgwRR3N9qVjuZ5s8tkiKEqJUuwAnpADhM09wJGr sxYMXP6eLAOmkr6A9LKAEUUAbXOwbX6sjh/CY= Subject: How to handle calling functions from cli From: Rodrick Brown Content-Type: text/plain; charset=us-ascii X-Mailer: iPhone Mail (9A405) Date: Fri, 24 Feb 2012 17:16:09 -0500 To: "python-list@python.org" Content-Transfer-Encoding: quoted-printable Mime-Version: 1.0 (1.0) X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.12 Precedence: list List-Id: General discussion list for the Python programming language List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Newsgroups: comp.lang.python Message-ID: Lines: 26 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1330121935 news.xs4all.nl 6859 [2001:888:2000:d::a6]:33164 X-Complaints-To: abuse@xs4all.nl Xref: x330-a1.tempe.blueboxinc.net comp.lang.python:20835 I have a bunch of sub routines that run independently to perform various sys= tem checks on my servers. I wanted to get an opinion on the following code I= have about 25 independent checks and I'm adding the ability to disable cert= ain checks that don't apply to certain hosts. m =3D { 'a': 'checkDisks()', 'b': 'checkMemSize()', 'c': 'checkBondInterfaces()' } =20 parser =3D argparse.ArgumentParser(description=3D'Parse command line arg= s.') parser.add_argument('-x', action=3D"store", dest=3D"d") r =3D parser.parse_args(sys.argv[1:]) =20 runlist =3D [ c for c in m.keys() if c not in r.d ] for runable in runlist: eval(m[runable]) I'm using temp variable names for now until I find an approach I like. Is this a good approach ? It doesn't look too pretty and to be honest feels a= wkward?=20 Sent from my iPhone