Path: csiph.com!fu-berlin.de!uni-berlin.de!not-for-mail From: Antoon Pardon Newsgroups: comp.lang.python Subject: Re: Case Statements Date: Wed, 16 Mar 2016 10:35:16 +0100 Lines: 30 Message-ID: References: <30502a2e-0bad-4b0f-a1e8-a2b40b0d7ab9@googlegroups.com> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-Trace: news.uni-berlin.de YHKmq6hgHTm3IgWTKpcMAA8AJ/oyn/HBcEtl4kdkhZ9g== Return-Path: X-Original-To: python-list@python.org Delivered-To: python-list@mail.python.org X-Spam-Status: OK 0.007 X-Spam-Evidence: '*H*': 0.99; '*S*': 0.00; 'received:134': 0.05; 'nasty': 0.07; 'statements': 0.09; 'bug': 0.10; 'python': 0.10; 'conditional': 0.16; 'constructs': 0.16; 'expression.': 0.16; 'received:ac.be': 0.16; 'received:io': 0.16; 'received:psf.io': 0.16; 'scripts.': 0.16; 'simulate': 0.16; 'simulated': 0.16; 'switch.': 0.16; 'shell': 0.18; 'developer': 0.20; 'otherwise,': 0.20; 'parsing': 0.22; 'header:In-Reply-To:1': 0.24; "i've": 0.25; 'header:User-Agent:1': 0.26; 'developers': 0.26; 'command': 0.26; 'switch': 0.27; 'used,': 0.27; 'least': 0.27; 'for,': 0.29; 'hash': 0.29; 'unlikely': 0.29; 'e.g.': 0.30; 'received:be': 0.30; 'guess': 0.31; 'core': 0.32; 'table': 0.32; 'generally': 0.32; 'statement': 0.32; 'languages': 0.34; 'gets': 0.35; 'but': 0.36; 'instead': 0.36; 'there': 0.36; 'to:addr:python-list': 0.36; 'subject:: ': 0.37; 'thought': 0.37; 'list.': 0.37; 'mailing': 0.38; 'enough': 0.39; 'to:addr:python.org': 0.40; 'where': 0.40; 'mark': 0.40; 'hope': 0.61; 'different': 0.63; 'interest': 0.64; 'six': 0.65; 'soon': 0.65; 'bitten': 0.84; 'pardon': 0.84; 'schreef': 0.84 X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: ArcKAFoo6VaGuA9G/2dsb2JhbABehGEBvCOGDQKCBgEBAQEBAWWEaQEBBCNLChELGgIFFgsCAgkDAgECAUUTCAKII683i1mECAEBCAIefIUihESFCII0gToFl1GBUIwxiSOFYo5/YoICGoFKi0wBAQE User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Icedove/38.5.0 In-Reply-To: X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: General discussion list for the Python programming language List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Xref: csiph.com comp.lang.python:104996 Op 16-03-16 om 09:47 schreef Mark Lawrence: > >> >> Same with switch. You can use a hash table etc. to simulate switches, >> but only if the codeblocks are independent. Otherwise, if-elif chains >> are the way to go. Command line parsing is a case where switch >> statements are often used, e.g. in shell scripts. > > I've seen at least six different ways of simulating switches, so those > people who want them, can have them. if-elif chains are not likely to > kill any Python programmer. > > I have no interest what other languages use switch/case statements > for, as we've on the PYTHON mailing list. There once were multiple ways to simulate a conditional expression. And it was generally thought that using if else statements instead of a conditional expression was unlikely to kill any Python programmer. But then one of the core developers was bitten by a nasty bug because he was using one of those constructs that simulated a conditional expression and soon enough Python had a conditional expression. So I guess those who would like a case statement in Python can only hope a core developer gets bitten by a nasty bug while using one of those ways of simulating switches. -- Antoon Pardon