Path: csiph.com!newsfeed.hal-mli.net!feeder3.hal-mli.net!newsfeed.hal-mli.net!feeder1.hal-mli.net!newsfeed.xs4all.nl!newsfeed4.news.xs4all.nl!xs4all!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.003 X-Spam-Evidence: '*H*': 0.99; '*S*': 0.00; 'table.': 0.07; 'pavel': 0.09; 'python': 0.11; 'translation': 0.12; 'times,': 0.14; "wouldn't": 0.14; '"got': 0.16; 'dict': 0.16; 'from:addr:rosuav': 0.16; 'from:name:chris angelico': 0.16; 'involved?': 0.16; 'statement.': 0.16; 'subject:tasks': 0.16; 'switch.': 0.16; 'subject:python': 0.16; 'do,': 0.16; 'wrote:': 0.18; 'trying': 0.19; 'thu,': 0.19; 'java': 0.24; 'switch': 0.26; 'header:In- Reply-To:1': 0.27; 'am,': 0.29; 'ideal': 0.29; 'statement': 0.30; 'message-id:@mail.gmail.com': 0.30; 'that.': 0.31; 'bunch': 0.31; 'table,': 0.31; 'languages': 0.32; 'implemented': 0.33; 'table': 0.34; 'but': 0.35; 'received:google.com': 0.35; 'there': 0.35; 'two': 0.37; 'implement': 0.38; 'nov': 0.38; 'to:addr:python- list': 0.38; 'to:addr:python.org': 0.39; 'solve': 0.60; "you're": 0.61; 'back': 0.62; '2013': 0.98 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :content-type; bh=rupTpJ0b4bVDfSgfFV0JQt0ASwsvB5lTvViSwTdMLHg=; b=QLGqJFd7bgpGNMLLm8biQFMgY/y491s5CGnWP+/S670A4SOK1hvGVq+vlzItqpxbGC xkgVZNN1GXwWyK24bztbhO1DMZENvDhpHpf7FO/aZb8/OWDt+MIZoc8NnB8ooKQ3Alof XonxLd7i9jYdHI0a+WK2T7ZTvg5XQa6etMbmwjypEHF6M0FhqQt8ZLc27RT9iMy3G5PZ 9VhdoN5A/Nt5MnxAXQoC1+l5Rp6Qju4GU9pJfWPeQHcm7pLz7nVidDx//pCBrv9InjFO 1B18wd+SZn1+zPZWTF1XbJUaG9AJ51fNzRd2iXvARPwJi10rhP9y8bp184snIcN7k+RE mzAg== MIME-Version: 1.0 X-Received: by 10.69.31.1 with SMTP id ki1mr7637603pbd.124.1385593894325; Wed, 27 Nov 2013 15:11:34 -0800 (PST) In-Reply-To: <27721690.YBritT5ChT@melforce> References: <5737051f-26d4-4771-b4a0-d41062f1a4ef@googlegroups.com> <52900c74$0$29993$c3e8da3$5496439d@news.astraweb.com> <27721690.YBritT5ChT@melforce> Date: Thu, 28 Nov 2013 10:11:34 +1100 Subject: Re: python for everyday tasks From: Chris Angelico To: python-list@python.org Content-Type: text/plain; charset=ISO-8859-1 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: 15 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1385593897 news.xs4all.nl 15917 [2001:888:2000:d::a6]:60751 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:60647 On Thu, Nov 28, 2013 at 5:05 AM, Pavel Volkov wrote: > "Got a switch statement? The Python translation is a hash table, not a bunch > of if-then statments. Got a bunch of if-then's that wouldn't be a switch > statement in Java because strings are involved? It's still a hash table. " I actually disagree. There is no Python translation for a switch statement. What you have is two ways (if/elif and dict lookup) to implement what in other languages is often implemented with a switch. Often, switch is used when a dispatch table is the ideal solution; but other times, neither if/elif nor a dispatch table will perfectly cover what you're trying to do, and it's not right to "translate" the switch into a dict lookup. The right thing to do is to go back to what's actually trying to be solved, and solve that. ChrisA