Path: csiph.com!usenet.pasdenom.info!news.albasani.net!rt.uk.eu.org!newsfeed.xs4all.nl!newsfeed1.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.011 X-Spam-Evidence: '*H*': 0.98; '*S*': 0.00; 'subject:Python': 0.06; '22,': 0.09; 'if,': 0.09; 'pointers': 0.09; 'subject:into': 0.09; 'cc:addr:python-list': 0.11; 'python': 0.11; '(last': 0.16; 'clarified': 0.16; 'exist.': 0.16; 'fluent': 0.16; 'from:addr:rosuav': 0.16; 'from:name:chris angelico': 0.16; 'objects.': 0.16; 'pointers,': 0.16; 'subject:variable': 0.16; 'sat,': 0.16; 'language': 0.16; 'wrote:': 0.18; 'variable': 0.18; 'passing': 0.19; 'feb': 0.22; 'cc:addr:python.org': 0.22; 'instance,': 0.24; '(or': 0.24; 'cc:2**0': 0.24; 'equivalent': 0.26; 'pass': 0.26; 'header:In-Reply-To:1': 0.27; 'message- id:@mail.gmail.com': 0.30; "i'm": 0.30; 'that.': 0.31; "d'aprano": 0.31; 'pascal': 0.31; 'steven': 0.31; 'probably': 0.32; 'but': 0.35; 'received:google.com': 0.35; 'subject:?': 0.36; 'should': 0.36; 'pm,': 0.38; 'anything': 0.39; 'does': 0.39; 'address.': 0.39; 'manually': 0.60; 'subject:Can': 0.60; 'ago,': 0.61; 'strictly': 0.61; 'you.': 0.62; 'address': 0.63; 'such': 0.63; 'more': 0.64; 'talking': 0.65; 'said:': 0.68; 'consequences': 0.74; 'address,': 0.75; 'bar)': 0.84; 'to:none': 0.92; 'yourself,': 0.95 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=rcGZImzZaNhLFJ/F7dyGRghu3a/C97zbNnvkeP7r7PI=; b=E+jKCIJxBqlyZTAW2qaQt4fnlJYOIf9p24kX1k6hMgfKG37GgCYvPshccd+yuQX+YZ p05N9pUvftNOZvcYpqwUf6NuSwWdooNa8qFV5iuL/LulcUm3Rh4bwH6u5t7+QRPC60SU E+DMWnNf0zaaXR3Nh3sdjeAxq0fgxrDOJvGiIqVE34pMA5mGe4sJihkGH+SGU3ryZLHC CPdBwwnBLrd6GforZ5CPY7eLtlh4UAFbSIksboEENo5IE0iYFIxpogOn0bBctAyhd9de xXkcsM1ZlFruRDVI4UP5mXPbUNcN4LlNHageGIrt1tD/tJ3X4OwrFNd/FoXMpjFgP9bq M5Yg== MIME-Version: 1.0 X-Received: by 10.68.108.194 with SMTP id hm2mr14082964pbb.22.1393054142696; Fri, 21 Feb 2014 23:29:02 -0800 (PST) In-Reply-To: <53084f42$0$29985$c3e8da3$5496439d@news.astraweb.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> Date: Sat, 22 Feb 2014 18:29: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: 23 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1393054151 news.xs4all.nl 2851 [2001:888:2000:d::a6]:44026 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:66880 On Sat, Feb 22, 2014 at 6:18 PM, Steven D'Aprano wrote: > Now I daresay that under the hood, Pascal is passing the address of foo > (or bar) to the procedure plus, but inside plus you don't see that > address as the value of b. You see the value of foo (or bar). > > C does not do that -- you have to manually manage the pointers yourself, > while Pascal does it for you. And Python also has nothing like that. Yep. I should have clarified that I wasn't talking about Pascal; I'm not fluent in the language (last time I did anything at all with Pascal was probably about ten years ago, and not much then). In C, it strictly does what I said: & takes the address of something, * dereferences an address. There's no way to "pass a variable" - you have to pass the address, and that has consequences if, for instance, you *return* an address and the variable ceases to exist. (Does Pascal have an equivalent of that?) And Python has no such concept, anywhere. But anything that you can achieve in C using pointers, you can probably achieve in Python using more complex objects. ChrisA