Path: csiph.com!fu-berlin.de!uni-berlin.de!not-for-mail From: Mark Lawrence Newsgroups: comp.lang.python Subject: Re: Case Statements Date: Wed, 16 Mar 2016 11:07:12 +0000 Lines: 72 Message-ID: References: <30502a2e-0bad-4b0f-a1e8-a2b40b0d7ab9@googlegroups.com> <56E928D4.3000701@rece.vub.ac.be> <56E93ADD.9040500@rece.vub.ac.be> Mime-Version: 1.0 Content-Type: text/plain; charset=windows-1252; format=flowed Content-Transfer-Encoding: 7bit X-Trace: news.uni-berlin.de gK+rzODmoKP1S4LZJI/R1Qw0irkQMezLiCEBIXgbXG5w== Return-Path: X-Original-To: python-list@python.org Delivered-To: python-list@mail.python.org X-Spam-Status: OK 0.002 X-Spam-Evidence: '*H*': 1.00; '*S*': 0.00; 'from:addr:yahoo.co.uk': 0.05; 'url:pipermail': 0.05; 'nasty': 0.07; 'get.': 0.09; 'porting': 0.09; 'received:80.91': 0.09; 'received:80.91.229': 0.09; 'received:gmane.org': 0.09; 'received:list': 0.09; 'statements': 0.09; 'bug': 0.10; 'python': 0.10; 'missed': 0.15; 'conditional': 0.16; 'constructs': 0.16; 'expression.': 0.16; 'make,': 0.16; 'received:80.91.229.3': 0.16; 'received:io': 0.16; 'received:plane.gmane.org': 0.16; 'received:psf.io': 0.16; 'scripts.': 0.16; 'simulate': 0.16; 'simulated': 0.16; 'switch.': 0.16; 'wsgi.': 0.16; 'wrote:': 0.16; 'bytes': 0.18; 'shell': 0.18; 'language': 0.19; '>>>': 0.20; 'developer': 0.20; 'otherwise,': 0.20; 'machine': 0.21; 'anonymous': 0.22; 'lawrence': 0.22; 'parsing': 0.22; '(or': 0.23; '(like': 0.23; 'header:In-Reply- To:1': 0.24; "i've": 0.25; 'header:User-Agent:1': 0.26; "doesn't": 0.26; 'developers': 0.26; 'command': 0.26; 'header:X-Complaints- To:1': 0.26; '(e.g.': 0.27; 'switch': 0.27; 'used,': 0.27; 'least': 0.27; 'for,': 0.29; 'hash': 0.29; 'unlikely': 0.29; 'raise': 0.29; 'starts': 0.29; 'code': 0.30; 'e.g.': 0.30; 'putting': 0.30; 'waste': 0.30; 'guess': 0.31; 'probably': 0.31; 'core': 0.32; 'table': 0.32; 'generally': 0.32; 'language.': 0.32; 'statement': 0.32; 'getting': 0.33; 'useful': 0.33; 'url:python': 0.33; 'doubt': 0.33; 'languages': 0.34; 'list': 0.34; 'gets': 0.35; 'done': 0.35; 'attempt': 0.35; 'something': 0.35; 'item': 0.35; 'but': 0.36; 'too': 0.36; 'should': 0.36; 'instead': 0.36; 'there': 0.36; 'url:org': 0.36; 'to:addr:python-list': 0.36; 'subject:: ': 0.37; 'received:org': 0.37; 'aspects': 0.37; 'thought': 0.37; 'list.': 0.37; 'things': 0.38; 'progress': 0.38; 'mailing': 0.38; 'enough': 0.39; 'url:mail': 0.40; 'to:addr:python.org': 0.40; 'where': 0.40; 'mark': 0.40; 'still': 0.40; 'hope': 0.61; 'charset:windows-1252': 0.62; 'different': 0.63; 'interest': 0.64; 'our': 0.64; 'six': 0.65; 'soon': 0.65; '>>>>>': 0.66; 'improvements': 0.66; 'here': 0.66; 'reply': 0.68; 'low': 0.83; 'areas,': 0.84; 'bitten': 0.84; 'functions)': 0.84; 'pardon': 0.84; 'pythonistas,': 0.84; 'schreef': 0.84; 'variation': 0.84; 'worthwhile.': 0.84; 'have.': 0.93 X-Injected-Via-Gmane: http://gmane.org/ X-Gmane-NNTP-Posting-Host: 80.234.129.0 User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:38.0) Gecko/20100101 Thunderbird/38.7.0 In-Reply-To: <56E93ADD.9040500@rece.vub.ac.be> 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:105004 On 16/03/2016 10:52, Antoon Pardon wrote: > Op 16-03-16 om 10:51 schreef Mark Lawrence: >> On 16/03/2016 09:35, Antoon Pardon wrote: >>> 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. >>> >> >> So that core developers can waste their time putting something into >> the language that we've done without for 25 years, yes, that strikes >> me as extremely worthwhile. > > Do you think python should stop progressing? Because all progress > python wil make, will be done by putting something in the language > we've done without for 25 years. > > That we have done without doesn't contradict it can be useful to have. > Raise the item on the python-ideas mailing list for the umpteenth time then, and see how far you get. The last attempt that I can find starts here https://mail.python.org/pipermail/python-ideas/2014-April/027665.html. The BDFL reply at https://mail.python.org/pipermail/python-ideas/2014-April/027667.html was:- I don't want to discourage you too much, but I think that adding a switch statement comes *very* low on the list of improvements we would like to make in Python 3.5. We should probably focus on speed (or aspects of it, like startup), language features that help porting Python 2 code to it (e.g. bytes formatting), and things that improve the user experience of getting started with Python on a new machine (e.g. pip/venv). Or perhaps stdlib issues like an asyncio-infused variation of WSGI. I've probably missed a few focus areas, but I still very much doubt we'll be adding a switch statement -- it's a "sexy" language design issue (like anonymous functions) but that's not what will help Python compete. -- My fellow Pythonistas, ask not what our language can do for you, ask what you can do for our language. Mark Lawrence