Path: csiph.com!usenet.pasdenom.info!aioe.org!news.stack.nl!newsfeed.xs4all.nl!newsfeed2.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.023 X-Spam-Evidence: '*H*': 0.96; '*S*': 0.00; 'args': 0.04; 'arguments,': 0.09; 'cleanly': 0.16; 'presume': 0.16; 'received:172.18.0': 0.16; 'thanks,': 0.18; 'to:name:python-list@python.org': 0.20; 'statement': 0.23; 'pass': 0.25; '8bit%:5': 0.29; 'switch': 0.32; 'to:addr:python-list': 0.33; 'there': 0.35; 'ability': 0.36; 'some': 0.38; 'to:addr:python.org': 0.39; 'received:unknown': 0.63; 'skip:n 10': 0.63 X-Cloudmark-SP-Filtered: true X-Cloudmark-SP-Result: v=1.1 cv=YO+FcVZrxpdWV6Mo6AkY2Rtp7tuV51ZJEd1ZQZEmJbs= c=1 sm=1 a=CRTDazI5n6YA:10 a=7PYXob_7ZXMA:10 a=BLceEmwcHowA:10 a=8nJEP1OIZ-IA:10 a=xqWC_Br6kY4A:10 a=oNw28mxuUhXRB3mVwYQ4Ag==:17 a=f9ahl2qUkSgw_m9SM5gA:9 a=wPNLvfGTeEIA:10 a=HpAAvcLHHh0Zw7uRqdWCyQ==:117 From: "Joseph L. Casale" To: "python-list@python.org" Subject: Switch statement Thread-Topic: Switch statement Thread-Index: AQHOHZi/ESFVWYLgCEa6JjfGB2X4CQ== Date: Sun, 10 Mar 2013 14:16:27 +0000 Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-originating-ip: [172.18.0.200] Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.15 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: 37 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1362925062 news.xs4all.nl 6860 [2001:888:2000:d::a6]:32809 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:41016 I have a switch statement composed using a dict:=0A= =0A= =0A= switch =3D {=0A= =A0 =A0 'a': func_a,=0A= =A0 =A0 'b':=A0func_b,=0A= =A0 =A0 'c':=A0func_c=0A= }=0A= switch.get(var, default)()=0A= =0A= =0A= As a result of multiple functions per choice, it migrated to:=0A= =0A= =0A= =0A= switch =3D {=0A= =A0 =A0 'a': (func_a1, func_a2),=0A= =A0 =A0 'b': (func_b1,=A0func_b2),=0A= =A0 =A0 'c': (func_c, )=0A= }=0A= =0A= =0A= =0A= for f in=A0switch.get(var, (default, )):=0A= =A0 =A0 f()=0A= =0A= =0A= As a result of only some of the functions now=A0requiring unique arguments,= I presume this=0A= needs to be migrated to a if/else statement? Is there a way to maintain the= switch style with=0A= the ability in this scenario to cleanly pass args only to some functions?= =0A= =0A= =0A= Thanks,=0A= jlc=