Path: csiph.com!usenet.pasdenom.info!aioe.org!news.stack.nl!newsfeed.xs4all.nl!newsfeed1a.news.xs4all.nl!xs4all!news.tele.dk!news.tele.dk!small.news.tele.dk!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.003 X-Spam-Evidence: '*H*': 0.99; '*S*': 0.00; 'subject:Python': 0.06; '22,': 0.09; 'subject:into': 0.09; 'variant': 0.09; 'cc:addr :python-list': 0.11; 'def': 0.12; 'b):': 0.16; 'from:addr:rosuav': 0.16; 'from:name:chris angelico': 0.16; 'subject:variable': 0.16; 'sat,': 0.16; 'wrote:': 0.18; 'feb': 0.22; 'cc:addr:python.org': 0.22; 'cc:2**0': 0.24; 'header:In-Reply-To:1': 0.27; 'rest': 0.29; 'message-id:@mail.gmail.com': 0.30; '>>>>': 0.31; 'received:google.com': 0.35; 'subject:?': 0.36; 'pm,': 0.38; 'subject:Can': 0.60; 'to:none': 0.92 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=8kuC5Y983qD73zP0X0kPRwh+zQBSRcNnBzn43++JRVY=; b=rqPEbRS5JCOqkBSBXOUl4Zuvqm3FmfQMixCdN+QRIyp2hQu4yqo/8oOSjo/hf3BdVf aaHkHDTkUbGUNUY2tQE6sL5ywBY4g4eV05X8Yfj2rR++cEoU2reiWEb1Iw5NWFk+ljBM a1o8KpdoYOMGAFZF4+A6Ngb6c2/NInyOdvHUDCzkgF/dpvvSp2D43E14tflWDpTWgJTk V2djBg2pIrAQ1xcb0setq8DyNC+Yq79jgOXWwzuhHR6107k0g/fTlj4aTsd10SenagBT teONu9s3mSPzlUGGRZPdZrd7yEj+enC8fKwJ7bpy7zOKhOcGp9zfZwqStG+GtYqYfaFu D/1Q== MIME-Version: 1.0 X-Received: by 10.68.112.164 with SMTP id ir4mr13676371pbb.153.1393056602252; Sat, 22 Feb 2014 00:10:02 -0800 (PST) In-Reply-To: <585851dd-6106-4bc0-a7a2-8679aaa6ea29@googlegroups.com> References: <27ac2248-0ca3-4ba6-9d25-eaad324bc5e9@googlegroups.com> <87sird7wuw.fsf@handshake.de> <8454E8CB-E6E3-452F-8E54-9A77BFF34EC2@gmail.com> <87bny0w9w3.fsf@elektro.pacujo.net> <53084f42$0$29985$c3e8da3$5496439d@news.astraweb.com> <585851dd-6106-4bc0-a7a2-8679aaa6ea29@googlegroups.com> Date: Sat, 22 Feb 2014 19:10:02 +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: 15 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1393056605 news.xs4all.nl 2899 [2001:888:2000:d::a6]:54669 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:66882 On Sat, Feb 22, 2014 at 7:02 PM, wrote: >>>> # a swapping variant >>>> def swap(a, b): > ... ab = [a, b] > ... ab[1], ab[0] = ab[0], ab[1] > ... return ab[0], ab[1] Provably identical to: def swap(a, b): return b, a The rest is just fluff. ChrisA