Path: csiph.com!usenet.pasdenom.info!weretis.net!feeder1.news.weretis.net!feeder.erje.net!eu.feeder.erje.net!newsfeed.xs4all.nl!newsfeed4.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.001 X-Spam-Evidence: '*H*': 1.00; '*S*': 0.00; 'from:addr:yahoo.co.uk': 0.04; 'subject:Python': 0.06; 'matches': 0.07; 'keys,': 0.09; '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; 'python': 0.11; 'language.': 0.14; 'hashable': 0.16; 'hashable,': 0.16; 'identities.': 0.16; 'objects.': 0.16; 'received:80.91.229.3': 0.16; 'received:plane.gmane.org': 0.16; 'subject:variable': 0.16; '(you': 0.16; 'do,': 0.16; 'language': 0.16; 'wrote:': 0.18; 'trying': 0.19; 'header:User-Agent:1': 0.23; 'fine': 0.24; '---': 0.24; 'possibly': 0.26; 'references': 0.26; 'switch': 0.26; 'header:X-Complaints-To:1': 0.27; 'header:In-Reply-To:1': 0.27; 'chris': 0.29; 'equality': 0.31; 'keys': 0.31; 'with,': 0.31; 'could': 0.34; 'problem': 0.35; 'case,': 0.35; 'point.': 0.35; 'but': 0.35; 'subject:?': 0.36; 'wrong': 0.37; 'so,': 0.37; 'too': 0.37; 'generic': 0.38; 'to:addr:python-list': 0.38; 'rather': 0.38; 'sure': 0.39; 'to:addr:python.org': 0.39; 'received:org': 0.40; 'how': 0.40; 'even': 0.60; 'subject:Can': 0.60; 'tell': 0.60; 'free': 0.61; 'viruses': 0.61; 'protection': 0.63; 'our': 0.64; 'more': 0.64; 'antivirus': 0.68; 'dict.': 0.84 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: Sun, 02 Mar 2014 16:53:06 +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> <87y50vwjq4.fsf@elektro.pacujo.net> <87d2i7wbxs.fsf@elektro.pacujo.net> <87bnxp58t7.fsf@elektro.pacujo.net> <87fvn08vux.fsf@elektro.pacujo.net> <87a9d88uoo.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-78-147-179-76.as13285.net User-Agent: Mozilla/5.0 (Windows NT 6.1; rv:24.0) Gecko/20100101 Thunderbird/24.3.0 In-Reply-To: X-Antivirus: avast! (VPS 140301-2, 01/03/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: 38 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1393779205 news.xs4all.nl 2971 [2001:888:2000:d::a6]:35507 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:67456 On 02/03/2014 16:23, Chris Angelico wrote: > > A switch block that works with constants and equality *can* be turned > into a dict. If the constants are hashable, use them as the keys > directly; if they're not hashable and/or you want to use object > identity as the criterion (effectively like using 'is' rather than > '==' for your case statements), use id(x) as the keys, and make sure > you have other references to the objects. Then it'll be fine as a > straight-up dict. > > If the switch block uses inequalities, then it suffers from the same > problem as the try/except block - it's inherently ordered, in case > (pun intended) there's a switched-on value that matches more than one. > (You could possibly optimize the int case, but that would be way WAY > too specific for a generic language structure.) > > ChrisA > You clearly don't get my point. I *DON'T* want to use stupid constants and stupid equalities, I want to use identities. I *DON'T* want to use stupid ==, I want to use 'is'. I *DON'T* care how many people with years of experience of Python tell me that this is the wrong thing to do, that is how I am going to do it. So, for the final time of asking, how do I do the above with, and only with, the identity, even if you stupidly keep on trying to tell me that this is wrong? -- 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