Path: csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!eu.feeder.erje.net!xlned.com!feeder5.xlned.com!newsfeed.xs4all.nl!newsfeed1a.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.003 X-Spam-Evidence: '*H*': 0.99; '*S*': 0.00; 'subject:Python': 0.06; 'variables': 0.07; 'from:addr:ethan': 0.09; 'from:addr:stoneleaf.us': 0.09; 'from:name:ethan furman': 0.09; 'key.': 0.09; 'message-id:@stoneleaf.us': 0.09; 'objects,': 0.09; '~ethan~': 0.09; 'python': 0.11; 'def': 0.12; "'a',": 0.16; 'wrote:': 0.18; 'passing': 0.19; 'print': 0.22; 'header:User- Agent:1': 0.23; 'pass': 0.26; 'header:In-Reply-To:1': 0.27; 'could': 0.34; 'but': 0.35; 'to:addr:python-list': 0.38; 'pm,': 0.38; 'to:addr:python.org': 0.39; 'even': 0.60; 'received:173': 0.61; 'subject:The': 0.64; 'subjectcharset:utf-8': 0.72; 'subject:have': 0.80; 'actually,': 0.84 Date: Wed, 07 May 2014 06:00:35 -0700 From: Ethan Furman User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:16.0) Gecko/20121010 Thunderbird/16.0.1 MIME-Version: 1.0 To: python-list@python.org Subject: Re: The =?UTF-8?B?4oCcZG9lcyBQeXRob24gaGF2ZSB2YXJpYWJsZXM/4oCdIGQ=?= =?UTF-8?B?ZWJhdGU=?= References: <235C4BFA-9770-481A-9FCF-21C3F036769C@gmail.com> <5368681D.8070602@islandtraining.com> <85zjiuea37.fsf_-_@benfinney.id.au> <8738gmxgay.fsf@elektro.pacujo.net> In-Reply-To: <8738gmxgay.fsf@elektro.pacujo.net> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-AntiAbuse: This header was added to track abuse, please include it with any abuse report X-AntiAbuse: Primary Hostname - gator3304.hostgator.com X-AntiAbuse: Original Domain - python.org X-AntiAbuse: Originator/Caller UID/GID - [47 12] / [47 12] X-AntiAbuse: Sender Address Domain - stoneleaf.us X-BWhitelist: no X-Source-IP: 173.12.184.233 X-Exim-ID: 1Wi1Sd-00031M-O4 X-Source: X-Source-Args: X-Source-Dir: X-Source-Sender: ([173.12.184.233]) [173.12.184.233]:58422 X-Source-Auth: ethan+stoneleaf.us X-Email-Count: 1 X-Source-Cap: dG9idWs7dG9idWs7Z2F0b3IzMzA0Lmhvc3RnYXRvci5jb20= 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: 28 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1399470412 news.xs4all.nl 2866 [2001:888:2000:d::a6]:53419 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:71019 On 05/06/2014 11:18 PM, Marko Rauhamaa wrote: > > Actually, while Python variables are not first-class objects, one could > see them as dictionary-key pairs. So you can even pass them by reference > by passing the dictionary and the key. Well, you could pass them that way, but not necessarily change them: --> def func1(): ... a = 1 ... b = 2 ... swap(locals(), 'a', 'b') ... print a ... print b ... --> def swap(d, key1, key2): ... print d[key1], d[key2] ... d[key1], d[key2] = d[key2], d[key1] ... print d[key1], d[key2] ... --> func1() 1 2 2 1 1 2 -- ~Ethan~