Path: csiph.com!news.mixmin.net!feeds.phibee-telecom.net!newsfeed.xs4all.nl!newsfeed7.news.xs4all.nl!news.tele.dk!news.tele.dk!small.news.tele.dk!newsgate.cistron.nl!newsgate.news.xs4all.nl!nzpost1.xs4all.net!not-for-mail Return-Path: X-Original-To: python-list@python.org Delivered-To: python-list@mail.python.org X-Spam-Status: OK 0.102 X-Spam-Level: * X-Spam-Evidence: '*H*': 0.80; '*S*': 0.01; 'cc:addr:python-list': 0.09; 'label,': 0.09; 'patterns,': 0.09; 'received:openend.se': 0.09; 'received:theraft.openend.se': 0.09; 'tuple': 0.09; 'cc:addr:lac': 0.16; 'cc:addr:openend.se': 0.16; 'from:addr:lac': 0.16; 'from:addr:openend.se': 0.16; 'from:name:laura creighton': 0.16; 'message-id:@fido.openend.se': 0.16; 'outcomes': 0.16; 'python3:': 0.16; 'received:fido': 0.16; 'received:fido.openend.se': 0.16; 'recipes': 0.16; 'which,': 0.16; 'laura': 0.18; 'stick': 0.18; 'cc:addr:python.org': 0.20; 'cc:2**1': 0.22; 'planet': 0.22; 'trying': 0.22; 'somewhere': 0.24; 'sort': 0.25; 'experiences': 0.27; 'device': 0.28; 'arguments,': 0.29; 'dictionary': 0.29; 'received:se': 0.29; 'repair': 0.29; 'ups': 0.29; 'url:se': 0.29; 'cc:no real name:2**1': 0.29; 'print': 0.30; 'probably': 0.31; 'problem': 0.33; 'values.': 0.33; 'case,': 0.34; 'know.': 0.34; 'could': 0.35; 'url:%3a': 0.35; 'something': 0.35; 'sometimes': 0.35; 'but': 0.36; 'there': 0.36; 'url:org': 0.36; 'data.': 0.36; 'depends': 0.36; 'url:source': 0.36; 'subject:: ': 0.37; 'really': 0.37; 'charset:us-ascii': 0.37; 'sure': 0.39; 'url:en': 0.39; 'well.': 0.40; 'your': 0.60; 'header:Message-Id:1': 0.61; 'url:t': 0.62; 'more': 0.63; 'our': 0.64; 'intent': 0.66; 'statement,': 0.66; 'box,': 0.67; 'worth': 0.67; 'yourself': 0.73; 'url:http': 0.75; '(a,': 0.84; 'dispatching': 0.84; 'guts': 0.84; 'header:In- reply-to:1': 0.84; 'players.': 0.84; 'url:cd': 0.84; 'url:readthedocs': 0.84; 'url:latest': 0.91; 'url:ved': 0.91; 'outcome': 0.93; 'plays': 0.93; 'url:j': 0.93; 'url:sa': 0.93; 'url:url': 0.93 To: Azureaus cc: python-list@python.org, lac@openend.se From: Laura Creighton Subject: Re: Phone Tree In-reply-to: <6ae5c632-b061-4b86-87ae-24c50435445b@googlegroups.com> References: <6ae5c632-b061-4b86-87ae-24c50435445b@googlegroups.com> Comments: In-reply-to Azureaus message dated "Sun, 13 Sep 2015 07:39:23 -0700." MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <23827.1442167391.1@fido> Content-Transfer-Encoding: quoted-printable Date: Sun, 13 Sep 2015 20:03:11 +0200 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.3.9 (theraft.openend.se [82.96.5.2]); Sun, 13 Sep 2015 20:03:13 +0200 (CEST) X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.20+ 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: 45 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1442167403 news.xs4all.nl 23828 [2001:888:2000:d::a6]:50214 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:96513 Somewhere in there you may find that dictionary dispatching is something worth doing. I don't know. This whole sort of problem is sort of grating, in that it is trying to replicate one of the most irritating user experiences on the planet ... =46rom python3: Patterns, Recipes and Idioms http://www.google.se/url?sa=3Dt&rct=3Dj&q=3D&esrc=3Ds&source=3Dweb&cd=3D5&= ved=3D0CEUQFjAEahUKEwiJv4CtxPTHAhVqvnIKHY68Bec&url=3Dhttp%3A%2F%2Fpython-3= -patterns-idioms-test.readthedocs.org%2Fen%2Flatest%2FMultipleDispatching.= html&usg=3DAFQjCNG0UFOKpxJNVDSCt9dtAJ55SC_zEA The guts of the thing is a simple dictionary: outcome =3D { (Paper, Rock): Outcome.WIN, (Paper, Scissors): Outcome.LOSE, (Paper, Paper): Outcome.DRAW, (Scissors, Paper): Outcome.WIN, (Scissors, Rock): Outcome.LOSE, (Scissors, Scissors): Outcome.DRAW, (Rock, Scissors): Outcome.WIN, (Rock, Paper): Outcome.LOSE, (Rock, Rock): Outcome.DRAW, } Which, in this case, plays the child's game rock, paper, scissors with 2 players. But you could use a tuple with 10 values. If a lot of your outcomes are going to arrive at the same answer 'Stick the device in a box, print off this shipping label, and send it via UPS to our repair service centre.' then this approach will have more appeal. Sometimes what you want is to dispatch on a set of functions with arguments, and you can stick that in your dictionary as well. outcomes =3D { (a,c,d) : (function1_name, (arg1, arg2, arg3)) (a, b, d) : (function2_name, (arg1,))} But whether this is going to help or not really depends on your data. If you find yourself itching for a case statement, then it probably will. But I am not sure that this was your intent in the first place. Laura