Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #41016
| 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 | <jcasale@activenetwerx.com> |
| 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" <jcasale@activenetwerx.com> |
| To | "python-list@python.org" <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 <python-list.python.org> |
| List-Unsubscribe | <http://mail.python.org/mailman/options/python-list>, <mailto:python-list-request@python.org?subject=unsubscribe> |
| List-Archive | <http://mail.python.org/pipermail/python-list/> |
| List-Post | <mailto:python-list@python.org> |
| List-Help | <mailto:python-list-request@python.org?subject=help> |
| List-Subscribe | <http://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe> |
| Newsgroups | comp.lang.python |
| Message-ID | <mailman.3155.1362925062.2939.python-list@python.org> (permalink) |
| 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 |
Show key headers only | View raw
I have a switch statement composed using a dict:
switch = {
'a': func_a,
'b': func_b,
'c': func_c
}
switch.get(var, default)()
As a result of multiple functions per choice, it migrated to:
switch = {
'a': (func_a1, func_a2),
'b': (func_b1, func_b2),
'c': (func_c, )
}
for f in switch.get(var, (default, )):
f()
As a result of only some of the functions now requiring unique arguments, I presume this
needs to be migrated to a if/else statement? Is there a way to maintain the switch style with
the ability in this scenario to cleanly pass args only to some functions?
Thanks,
jlc
Back to comp.lang.python | Previous | Next — Next in thread | Find similar | Unroll thread
Switch statement "Joseph L. Casale" <jcasale@activenetwerx.com> - 2013-03-10 14:16 +0000
Re: Switch statement Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2013-03-10 15:18 +0000
RE: Switch statement "Joseph L. Casale" <jcasale@activenetwerx.com> - 2013-03-10 17:51 +0000
Re: Switch statement Terry Reedy <tjreedy@udel.edu> - 2013-03-10 18:02 -0400
csiph-web