Path: csiph.com!usenet.pasdenom.info!gegeweb.org!usenet-fr.net!nerim.net!novso.com!newsfeed.xs4all.nl!newsfeed4a.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.007 X-Spam-Evidence: '*H*': 0.99; '*S*': 0.00; 'subject:: [': 0.04; 'subject:Python': 0.06; '*is*': 0.09; 'lawrence': 0.09; 'stack,': 0.09; 'structure,': 0.09; 'subject:into': 0.09; 'cc:addr:python- list': 0.11; 'from:addr:rosuav': 0.16; 'from:name:chris angelico': 0.16; 'heap,': 0.16; 'invisible': 0.16; 'subject:variable': 0.16; 'wrote:': 0.18; 'subject:] ': 0.20; 'memory': 0.22; 'cc:addr:python.org': 0.22; 'pointer': 0.24; 'mon,': 0.24; 'cc:2**0': 0.24; 'header:In-Reply-To:1': 0.27; 'function': 0.29; 'correct': 0.29; 'am,': 0.29; "doesn't": 0.30; 'newer': 0.30; 'message-id:@mail.gmail.com': 0.30; 'object.': 0.31; 'public.': 0.31; 'struct': 0.31; 'actual': 0.34; 'table': 0.34; 'but': 0.35; 'received:google.com': 0.35; 'c++': 0.36; "i'll": 0.36; 'subject:?': 0.36; 'virtual': 0.37; 'that,': 0.38; 'does': 0.39; 'structure': 0.39; 'subject:Can': 0.60; 'first': 0.61; 'address': 0.63; 'field': 0.63; 'believe': 0.68; 'mar': 0.68; 'containing': 0.69; 'edwards': 0.91; '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=3EMGj/VDii6/RiA7wAMywijGf+6wmVUBgGNGobl02aA=; b=R+1Da4EKeBBl2qfXLh2B7/aEVLxD++ajmCw42I1Adnit9+PY72aEQWWtD7v8uALfCh vYgwkhGfyvEeR1w3lGQl7TOqsvEfy8jKZSzcJ8pWRp70RFh2j1DlDwiTbUo7+FzVj2ft P4y/CWapCWCwuub6W3u1qe94tx67mCB3upcdBN9qJXmA2kez0nu25FybBSljtLjKZ/hr 8T2jdkLMSh6CTGQm1VeNhZsA9p64Xz/Zlkwl+lqO1NLeaunVCJliMetmZe9vE21VNKws FygtzvIHZ+8iVsXgrlN3U7iiD0C3jDz8a0BlE3AQfHNV5tKXmuw1Ka0isnkdlnrf5nJZ xmzQ== MIME-Version: 1.0 X-Received: by 10.66.192.162 with SMTP id hh2mr938413pac.150.1393788256571; Sun, 02 Mar 2014 11:24:16 -0800 (PST) In-Reply-To: References: <27ac2248-0ca3-4ba6-9d25-eaad324bc5e9@googlegroups.com> <87sird7wuw.fsf@handshake.de> <8454E8CB-E6E3-452F-8E54-9A77BFF34EC2@gmail.com> <1m3gg9lbf2ln5m2kbki954t17mqni3b20k@4ax.com> <53095145$0$29985$c3e8da3$5496439d@news.astraweb.com> <877g8mcg1m.fsf@elektro.pacujo.net> <87ob1yay9m.fsf@elektro.pacujo.net> <08aa32de-cd51-4888-bd60-2c2b53d86ecc@googlegroups.com> Date: Mon, 3 Mar 2014 06:24:16 +1100 Subject: Re: [OT] 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: 25 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1393788264 news.xs4all.nl 2971 [2001:888:2000:d::a6]:33197 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:67461 On Mon, Mar 3, 2014 at 3:55 AM, Mark Lawrence wrote: > On 02/03/2014 16:45, Grant Edwards wrote: >> >> >> That's irrelevent. The actual location of the memory containing the >> struct object (static, stack, heap, shared) doesn't matter. The >> address of the first field in a struture object _is_ the address of >> the structure object. >> > > You say struture, I'll say structure, let's call the whole thing off :) :) Note that, technically, Grant is correct as long as you grant (heh) that a structure may have an invisible member, the virtual function table pointer. C++ only (I don't believe C has virtual functions - but it may have grown them in one of the newer standards), so in C, all members are public. With an array, the array's pointer *is* the same as the pointer to its first member, because adding zero to a pointer does nothing, and x <-> &x[0] <-> &(*(x+0)). ChrisA