Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #41042

RE: Switch statement

Path csiph.com!usenet.pasdenom.info!weretis.net!feeder1.news.weretis.net!feeder.erje.net!eu.feeder.erje.net!xlned.com!feeder1.xlned.com!news2.euro.net!newsgate.cistron.nl!newsgate.news.xs4all.nl!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.95; '*S*': 0.00; 'args': 0.04; 'case.': 0.05; 'none,': 0.05; 'appropriate.': 0.09; 'guys!': 0.09; 'lambda': 0.16; 'received:172.18.0': 0.16; 'to:name:python- list@python.org': 0.20; '&gt;': 0.23; 'pass': 0.25; 'header:In- Reply-To:1': 0.25; 'arguments.': 0.29; 'worked': 0.30; 'function': 0.30; 'suggestion': 0.32; 'could': 0.32; 'like:': 0.33; 'to:addr :python-list': 0.33; 'skip:d 20': 0.34; 'thanks': 0.34; 'especially': 0.35; 'something': 0.35; 'there': 0.35; 'charset:us- ascii': 0.36; 'well.': 0.37; 'subject:: ': 0.38; 'some': 0.38; 'to:addr:python.org': 0.39; 'called': 0.39; 'easy': 0.60; 'most': 0.61; 'different': 0.63; 'received:unknown': 0.63; 'within': 0.64; 'fact,': 0.69
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=xqWC_Br6kY4A:10 a=oNw28mxuUhXRB3mVwYQ4Ag==:17 a=NGOQQrtOlQj73J9GMWYA:9 a=CjuIK1q_8ugA:10 a=yYls_xZeWIgWWiZljTUA:9 a=_W_S_7VecoQA:10 a=frz4AuCg-hUA:10 a=Zg4X-VmYMOT6zIIy:21 a=HpAAvcLHHh0Zw7uRqdWCyQ==:117
From "Joseph L. Casale" <jcasale@activenetwerx.com>
To "python-list@python.org" <python-list@python.org>
Subject RE: Switch statement
Thread-Topic Switch statement
Thread-Index AQHOHdAzoGPFc7fw1UePzo9IXt3xQJif23iA//+ii+g=
Date Sun, 10 Mar 2013 22:18:37 +0000
References <f529f94d99404cefa9b832ebf57d2898@exch.activenetwerx.com> <CAAu18hdW99y9MxEatrps3fMopqZk7A=J_78+zXj_4o1-ncJ1nQ@mail.gmail.com>
In-Reply-To <CAAu18hdW99y9MxEatrps3fMopqZk7A=J_78+zXj_4o1-ncJ1nQ@mail.gmail.com>
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 multipart/alternative; boundary="_000_1ebcb3be6cad4704aa7304bb10c9bfd3exchactivenetwerxcom_"
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.3171.1362953935.2939.python-list@python.org> (permalink)
Lines 85
NNTP-Posting-Host 2001:888:2000:d::a6
X-Trace 1362953935 news.xs4all.nl 6891 [2001:888:2000:d::a6]:58909
X-Complaints-To abuse@xs4all.nl
Xref csiph.com comp.lang.python:41042

Show key headers only | View raw


[Multipart message — attachments visible in raw view] - view raw

> Or could you do something like:
>
> arguments_to_pass = [list of some sort]
> switch.get(var, default)(*arguments_to_pass)

Stevens lambda suggestion was most appropriate. Within the switch, there
are functions called with none, or some variation of arguments. It was not
easy to pass them in after the fact, especially since the same function may
have different args depending on which case.

The lamda worked well.

Thanks guys!
jlc

Back to comp.lang.python | Previous | Next | Find similar | Unroll thread


Thread

RE: Switch statement "Joseph L. Casale" <jcasale@activenetwerx.com> - 2013-03-10 22:18 +0000

csiph-web