Path: csiph.com!usenet.pasdenom.info!news.etla.org!news.stack.nl!newsfeed.xs4all.nl!newsfeed3a.news.xs4all.nl!xs4all!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.014 X-Spam-Evidence: '*H*': 0.97; '*S*': 0.00; 'programmer': 0.03; 'elif': 0.05; 'subject:Python': 0.06; 'subject:into': 0.09; 'cc:addr :python-list': 0.11; 'python': 0.11; '8:40': 0.16; 'chris,': 0.16; 'from:addr:rosuav': 0.16; 'from:name:chris angelico': 0.16; 'readable': 0.16; 'subject:variable': 0.16; 'sure.': 0.16; 'language': 0.16; 'wrote:': 0.18; 'looked': 0.18; 'cc:addr:python.org': 0.22; 'cc:2**0': 0.24; 'equivalent': 0.26; 'switch': 0.26; 'header:In-Reply-To:1': 0.27; 'am,': 0.29; 'primarily': 0.30; 'statement': 0.30; 'message- id:@mail.gmail.com': 0.30; 'easier': 0.31; 'default,': 0.31; 'go.': 0.31; 'figure': 0.32; 'but': 0.35; 'received:google.com': 0.35; 'there': 0.35; 'subject:?': 0.36; 'two': 0.37; 'version,': 0.38; "couldn't": 0.39; 'users': 0.40; 'how': 0.40; 'read': 0.60; 'chain': 0.60; 'subject:Can': 0.60; "you're": 0.61; 'show': 0.63; 'mar': 0.68; 'improvement,': 0.84; "it'd": 0.84; 'mock': 0.84; 'to:none': 0.92; 'average': 0.93 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:cc :content-type; bh=hHzhLfyulVuFznzB3KIamD1n6GCsvCHIKXggzGMZ7Xk=; b=R0/fBfWDdz4GGflOimc9XwlzbxjJtD6zDeTZ5Z1GCWGhgjvyLsWEYZcLxiGjQq/lfL x8rLrUhrx1rA+gMFNysaOWOMQNQ9D1781+oXmO+aR3snBbu5eLJdDVtSy/PYXvQUl8bT owhDtXdpO3tpIz8qrlMibxkYY9pw+nDnNUw93o/6IXjbOwunjSD/x1jq2xkyHowQ7MVe t+wNWnpCxmHYDLdzMpaYh500qSX1ETkqPug4BYDXe8GDtR8Ir6XzjEGhCl56he7AXICK Z4UtpBlfI0zWATQJQT/JMk3I35LMD2XIfQL2xcxPlDYQDrHwrI8N0Iw8x5bUgI6k5Pkj IliA== MIME-Version: 1.0 X-Received: by 10.66.145.230 with SMTP id sx6mr2334010pab.47.1393711881421; Sat, 01 Mar 2014 14:11:21 -0800 (PST) In-Reply-To: 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> <5310b031$0$29985$c3e8da3$5496439d@news.astraweb.com> <87iorzf4ro.fsf@elektro.pacujo.net> <877g8ff3hn.fsf@elektro.pacujo.net> <87wqgfdk6a.fsf@elektro.pacujo.net> <0b414429-74ee-45dd-9465-c87e98c362f2@googlegroups.com> <4bd11eec-395a-4484-a991-9fabf12328e1@googlegroups.com> <2633c4d3-e8cc-47fa-b22a-48dab2ef1a29@googlegroups.com> Date: Sun, 2 Mar 2014 09:11:21 +1100 Subject: Re: Can global variable be passed into Python function? From: Chris Angelico Cc: "python-list@python.org" Content-Type: text/plain; charset=UTF-8 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: 17 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1393711891 news.xs4all.nl 2957 [2001:888:2000:d::a6]:36385 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:67379 On Sun, Mar 2, 2014 at 8:40 AM, Mark H. Harris wrote: > hi Chris, I don't think you're wrong. There are two issues for me (and one of them is not how the switch is implemented). > > 1) Is it easier for average users of python as a language to read switch case default, or if elif else ? > > I personally can see and understand a switch block 2x to 3x faster than looking at an elif chain. Because I am primarily a C programmer and I personally use and read switch blocks. Sure. But before you can ask us to consider how readable it is, we need to have comparisons. Mock up a switch statement equivalent and show us how it'd be better. I just looked at your version, and couldn't see any way that it would be an improvement, because it required that there be the exact same if/elif chain to figure out what to switch on. So give us your readable version, in an exact reimplementation of the if/elif chain, so we can see exactly how it would go. ChrisA