Path: csiph.com!usenet.pasdenom.info!news.albasani.net!rt.uk.eu.org!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.001 X-Spam-Evidence: '*H*': 1.00; '*S*': 0.00; 'else:': 0.03; 'from:addr:yahoo.co.uk': 0.04; 'elif': 0.05; 'subject:Python': 0.06; 'lawrence': 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; 'language.': 0.14; '"="': 0.16; '"mark': 0.16; '*you*': 0.16; 'compare.': 0.16; 'compatible,': 0.16; 'operator.': 0.16; 'received:80.91.229.3': 0.16; 'received:plane.gmane.org': 0.16; 'subject:variable': 0.16; 'language': 0.16; 'wrote:': 0.18; 'header:User-Agent:1': 0.23; '---': 0.24; 'header:X-Complaints-To:1': 0.27; 'header:In-Reply- To:1': 0.27; 'point': 0.28; 'statement': 0.30; "skip:' 10": 0.31; 'url:wiki': 0.31; '(my': 0.31; 'another.': 0.31; 'compatible': 0.32; 'equal': 0.35; 'false': 0.36; 'subject:?': 0.36; 'to:addr :python-list': 0.38; 'to:addr:python.org': 0.39; 'received:org': 0.40; 'subject:Can': 0.60; 'free': 0.61; 'viruses': 0.61; 'protection': 0.63; 'skip:n 10': 0.64; 'our': 0.64; 'more': 0.64; 'antivirus': 0.68; 'anything.': 0.68; 'received:89': 0.85 X-Injected-Via-Gmane: http://gmane.org/ To: python-list@python.org From: Mark Lawrence Subject: Re: Can global variable be passed into Python function? Date: Fri, 28 Feb 2014 21:23:36 +0000 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> Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Gmane-NNTP-Posting-Host: host-89-240-161-236.as13285.net User-Agent: Mozilla/5.0 (Windows NT 6.1; rv:24.0) Gecko/20100101 Thunderbird/24.3.0 In-Reply-To: <87wqgfdk6a.fsf@elektro.pacujo.net> X-Antivirus: avast! (VPS 140228-3, 28/02/2014), Outbound message X-Antivirus-Status: Clean 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: 63 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1393622633 news.xs4all.nl 2978 [2001:888:2000:d::a6]:47595 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:67250 On 28/02/2014 21:03, Marko Rauhamaa wrote: > "Mark H. Harris" : > >> Yep, my point exactly. nice illustration. > > So now, for you and me: let's compare. > > if key is ast.Assign: > return ' '.join(dump(t) for t in node.targets) > elif key is ast.AugAssign: > # Same target and same operator. > return dump(node.target) + dump(node.op) + "=" > elif key is ast.Return: > # A return statement is always compatible with another. > return "(easy)" > elif key is ast.Expr: > # Calling these never compatible is wrong. Calling them > # always compatible will give lots of false positives. > return "(maybe)" > else: > # These ones are never compatible, so return some > # object that's never equal to anything. > return float("nan") > > vs (my proposal): > > with key from ast: > if Assign: > return ' '.join(dump(t) for t in node.targets) > elif AugAssign: > # Same target and same operator. > return dump(node.target) + dump(node.op) + "=" > elif Return: > # A return statement is always compatible with another. > return "(easy)" > elif Expr: > # Calling these never compatible is wrong. Calling them > # always compatible will give lots of false positives. > return "(maybe)" > else: > # These ones are never compatible, so return some > # object that's never equal to anything. > return float("nan") > > Which do *you* find more readable? > > > Marko > http://c2.com/cgi/wiki?SwitchStatementsSmell -- My fellow Pythonistas, ask not what our language can do for you, ask what you can do for our language. Mark Lawrence --- This email is free from viruses and malware because avast! Antivirus protection is active. http://www.avast.com