Path: csiph.com!usenet.pasdenom.info!weretis.net!feeder4.news.weretis.net!rt.uk.eu.org!newsfeed.xs4all.nl!newsfeed2a.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.000 X-Spam-Evidence: '*H*': 1.00; '*S*': 0.00; 'python.': 0.02; 'python,': 0.02; 'subject:Python': 0.06; 'compiler': 0.07; 'parsers': 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; 'subject:into': 0.09; 'python': 0.11; "wouldn't": 0.14; 'bit.': 0.16; 'internally': 0.16; 'pythonic': 0.16; 'readability': 0.16; 'received:80.91.229.3': 0.16; 'received:plane.gmane.org': 0.16; 'statement.': 0.16; 'subject:variable': 0.16; 'switch.': 0.16; 'language': 0.16; 'wrote:': 0.18; 'unlike': 0.19; 'fit': 0.20; 'example': 0.22; 'header:User-Agent:1': 0.23; 'example.': 0.24; 'switch': 0.26; 'tables': 0.26; 'header:X-Complaints-To:1': 0.27; 'chris': 0.29; "doesn't": 0.30; 'statement': 0.30; 'fighting': 0.31; 'could': 0.34; 'except': 0.35; 'but': 0.35; 'charset:us-ascii': 0.36; 'subject:?': 0.36; 'awesome': 0.38; 'to:addr:python-list': 0.38; 'to:addr:python.org': 0.39; 'enough': 0.39; 'received:org': 0.40; 'remove': 0.60; 'easy': 0.60; 'subject:Can': 0.60; 'break': 0.61; "you'll": 0.62; 'provide': 0.64; 'benefit': 0.68; 'cultural': 0.74; '*really*': 0.84; 'facility.': 0.84; 'tide': 0.84; 'proposal,': 0.91 X-Injected-Via-Gmane: http://gmane.org/ To: python-list@python.org From: Neil Cerutti Subject: Re: Can global variable be passed into Python function? Date: Fri, 28 Feb 2014 13:47:02 +0000 (UTC) Organization: Norwich University References: <27ac2248-0ca3-4ba6-9d25-eaad324bc5e9@googlegroups.com> <5f4f5a5f-327a-4616-8235-17ee9e74c488@googlegroups.com> <530fef58$0$11113$c3e8da3@news.astraweb.com> <871tynznpd.fsf@elektro.pacujo.net> <53104798$0$11113$c3e8da3@news.astraweb.com> <87ha7jy2qs.fsf@elektro.pacujo.net> <87y50vwjq4.fsf@elektro.pacujo.net> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit X-Gmane-NNTP-Posting-Host: jackman.norwich.edu User-Agent: slrn/0.9.9p1/mm/ao (Win32) 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: 29 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1393595250 news.xs4all.nl 2978 [2001:888:2000:d::a6]:39483 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:67220 On 2014-02-28, Marko Rauhamaa wrote: > Chris Angelico : >> Python currently has dispatch tables and if/elif chains, and a >> strong cultural aversion to switch. You could change that by >> coming up with some *really* awesome proposal, but you'll be >> fighting against the tide a bit. > > It's easy have a "cultural aversion" when the language doesn't > provide the facility. > > Switch statements provide for excellent readability in parsers > and state machines, for example. They also allow the Python > compiler to optimize the statement internally unlike long > if-else chains. Once you remove all the features of switch that wouldn't fit in Python, e.g.; fall-through, jumps, breaks; whats left provides negligible benefit over if-elif-else or dict-dispatch. A pythonic switch statement doesn't provide enough features to bother with its implemention. Check out Go's switch statement for an example of what it might look like in Python. Except you'd get it without labeled break or the fallthrough statement. Would you still want to use it? -- Neil Cerutti