Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #41023
| Path | csiph.com!usenet.pasdenom.info!weretis.net!feeder4.news.weretis.net!ecngs!feeder2.ecngs.de!newsfeed.freenet.ag!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.039 |
| X-Spam-Evidence | '*H*': 0.92; '*S*': 0.00; 'applicable,': 0.07; 'slightly': 0.15; 'a),': 0.16; 'lambda': 0.16; 'received:172.18.0': 0.16; 'to:name:python-list@python.org': 0.20; "haven't": 0.23; 'header:In-Reply-To:1': 0.25; 'appreciated': 0.27; 'skip:> 10': 0.27; '8bit%:5': 0.29; 'switch': 0.32; 'to:addr :python-list': 0.33; 'but': 0.36; 'should': 0.36; 'ok,': 0.37; 'subject:: ': 0.38; 'to:addr:python.org': 0.39; 'received:unknown': 0.63; 'more': 0.63 |
| X-Cloudmark-SP-Filtered | true |
| X-Cloudmark-SP-Result | v=1.1 cv=af5CIMo/LcwhE/oGmlIBzBFfdATRqF9T4efLO6x9hFM= 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=fG8tDqOYOoB8kULJ8cQA:9 a=wPNLvfGTeEIA:10 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 | AQHOHaJ4ESFVWYLgCEa6JjfGB2X4CZifM/y/ |
| Date | Sun, 10 Mar 2013 17:51:58 +0000 |
| References | <513ca430$0$6512$c3e8da3$5496439d@news.astraweb.com> |
| In-Reply-To | <513ca430$0$6512$c3e8da3$5496439d@news.astraweb.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 | 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.3157.1362937989.2939.python-list@python.org> (permalink) |
| Lines | 20 |
| NNTP-Posting-Host | 2001:888:2000:d::a6 |
| X-Trace | 1362937989 news.xs4all.nl 6910 [2001:888:2000:d::a6]:40092 |
| X-Complaints-To | abuse@xs4all.nl |
| Xref | csiph.com comp.lang.python:41023 |
Show key headers only | View raw
> switch = {
> 'A': functools.partial(spam, a),
> 'B': lambda b, c=c: ham(b, c),
> 'C': eggs,
> }
>
> switch[letter](b)
That's cool, never even thought to use lambdas.
> functools.partial isn't always applicable, but when it is, you should
> prefer it over lambda since it will be very slightly more efficient.
Ok, haven't used this before but I will give it a read!
Much appreciated Steven!
jlc
Back to comp.lang.python | Previous | Next — Previous in thread | 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