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: 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" To: "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 List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Newsgroups: comp.lang.python Message-ID: 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 > switch =3D {=A0=0A= =0A= >=A0=A0=A0=A0 'A': functools.partial(spam, a),=0A= >=A0=A0=A0=A0 'B': lambda b, c=3Dc: ham(b, c),=0A= >=A0=A0=A0=A0 'C': eggs,=0A= >=A0=A0=A0=A0 }=0A= >=A0=0A= >=A0switch[letter](b)=0A= =0A= That's cool, never even thought to use lambdas.=0A= =0A= > functools.partial isn't always applicable, but when it is, you should=0A= >=A0prefer it over lambda since it will be very slightly more efficient.=0A= =0A= =0A= Ok, haven't used this before but I=A0will=A0give it a read!=0A= =0A= =0A= Much appreciated Steven!=0A= jlc=