Path: csiph.com!usenet.pasdenom.info!aioe.org!news.stack.nl!newsfeed.xs4all.nl!newsfeed2a.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.000 X-Spam-Evidence: '*H*': 1.00; '*S*': 0.00; 'else:': 0.03; 'elif': 0.05; 'subject:Python': 0.06; 'strict': 0.07; 'coders': 0.09; 'elegant,': 0.09; 'essential.': 0.09; 'friday,': 0.09; 'function:': 0.09; 'question?': 0.09; 'received:80.91': 0.09; 'received:80.91.229': 0.09; 'received:gmane.org': 0.09; 'received:list': 0.09; 'subject:into': 0.09; 'python': 0.11; 'useful,': 0.14; 'block.': 0.16; 'indent': 0.16; 'paradigm.': 0.16; 'readable': 0.16; 'received:80.91.229.3': 0.16; 'received:plane.gmane.org': 0.16; 'selected.': 0.16; 'statement.': 0.16; 'subject:variable': 0.16; 'third,': 0.16; 'language': 0.16; 'wrote:': 0.18; "python's": 0.19; 'header:User-Agent:1': 0.23; 'necessary.': 0.24; 'received:comcast.net': 0.24; 'first,': 0.26; 'switch': 0.26; 'least': 0.26; 'skip:_ 20': 0.27; 'header:X -Complaints-To:1': 0.27; 'header:In-Reply-To:1': 0.27; "doesn't": 0.30; 'besides': 0.30; 'statement': 0.30; 'code': 0.31; 'breaking': 0.31; 'second,': 0.31; 'skip:_ 10': 0.34; "can't": 0.35; 'but': 0.35; 'there': 0.35; 'really': 0.36; 'subject:?': 0.36; 'clear': 0.37; 'expressed': 0.37; 'to:addr:python-list': 0.38; 'pm,': 0.38; 'that,': 0.38; 'does': 0.39; 'though,': 0.39; 'to:addr:python.org': 0.39; 'received:org': 0.40; 'chain': 0.60; 'subject:Can': 0.60; 'most': 0.60; 'simple': 0.61; "you're": 0.61; 'first': 0.61; 'show': 0.63; 'more': 0.64; 'here': 0.66; 'between': 0.67; 'therefore': 0.72; 'conclude': 0.84; 'neck,': 0.84; 'pain': 0.84; 'ugly,': 0.84; 'absolutely': 0.87 X-Injected-Via-Gmane: http://gmane.org/ To: python-list@python.org From: Ned Batchelder Subject: Re: Can global variable be passed into Python function? Date: Fri, 28 Feb 2014 19:40:06 -0500 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> Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Gmane-NNTP-Posting-Host: c-50-133-228-126.hsd1.ma.comcast.net User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.8; rv:24.0) Gecko/20100101 Thunderbird/24.3.0 In-Reply-To: <0b414429-74ee-45dd-9465-c87e98c362f2@googlegroups.com> 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: 35 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1393634419 news.xs4all.nl 2978 [2001:888:2000:d::a6]:38128 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:67264 On 2/28/14 6:36 PM, Mark H. Harris wrote: > On Friday, February 28, 2014 3:03:25 PM UTC-6, Marko Rauhamaa wrote: >> >> Marko > > ... and between me and you, here is a snip from dmath.py from the atan(x) function: > > if (n**2 < D(1)): > a = __atan__(n) > elif (n == D(1)): > a = gpi/4 > elif (n == D(-1)): > a = -(gpi/4) > elif (n < D(-1)): > a = __atan__Lt_neg1__(n) > else: > a = __atan__Gt_1__(n) > > This if--elif--else is not only ugly, its just not readable either, and besides that, its not elegant, nor is it humanly helpful... its does work though, and its absolutely necessary. ugh. > > First, its not immediately clear what it does. Well, there isn't just one atan(x) routine, there are at least four of them, depending on whether you're a purist, and they must be selected. > > Second, because of the strict intent ideology of python in the first place, I can't indent this code to make it more readable without breaking python's syntax. > > Third, this is a VERY simple if elif block. More complex ones are much worse... for human reading that is... > > I know its a pain in the neck, but python does need a switch statement. Is it a stubborn question? I don't really think that almost every modern computer language has a switch block because of some C paradigm. I think its because most coders find them useful, at least readable, and therefore essential. I don't understand: you show an if/elif chain that cannot be expressed as a switch statement (because it uses < ), and then conclude that Python needs a switch statement? That doesn't make any sense. -- Ned Batchelder, http://nedbatchelder.com