Path: csiph.com!usenet.pasdenom.info!weretis.net!feeder4.news.weretis.net!feeds.phibee-telecom.net!newsfeed.xs4all.nl!newsfeed6.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.002 X-Spam-Evidence: '*H*': 1.00; '*S*': 0.00; 'python.': 0.02; 'subject:Python': 0.05; 'compiler': 0.05; 'variables.': 0.07; 'broke': 0.09; 'integer,': 0.09; 'pointers': 0.09; 'subtract': 0.09; 'typedef': 0.09; 'aug': 0.13; '24,': 0.16; 'arithmetic.': 0.16; 'from:addr:rosuav': 0.16; 'from:name:chris angelico': 0.16; 'hides': 0.16; 'integers.': 0.16; 'pointers.': 0.16; 'subject:Objects': 0.16; 'wrote:': 0.17; 'integer': 0.17; 'pointer': 0.17; 'obviously': 0.18; '(or': 0.18; 'received:209.85.214.174': 0.21; 'task': 0.23; 'least': 0.25; 'header:In-Reply-To:1': 0.25; 'am,': 0.27; 'done.': 0.27; 'message-id:@mail.gmail.com': 0.27; "doesn't": 0.28; 'chris': 0.28; 'environment': 0.29; 'arithmetic': 0.29; 'pointer.': 0.29; 'probably': 0.29; 'fri,': 0.30; 'stuff': 0.30; 'sense': 0.31; 'could': 0.32; 'to:addr:python-list': 0.33; 'received:google.com': 0.34; "won't": 0.35; 'received:209.85': 0.35; 'there': 0.35; 'add': 0.36; 'explain': 0.36; 'but': 0.36; 'two': 0.37; 'received:209': 0.37; 'subject:: ': 0.38; 'fact': 0.38; 'object': 0.38; 'nothing': 0.38; 'there,': 0.38; 'to:addr:python.org': 0.39; 'received:209.85.214': 0.39; 'header:Received:5': 0.40; 'help': 0.40; 'think': 0.40; "you've": 0.61; 'back': 0.62; 'here': 0.65; 'guaranteed': 0.76; "'foo'": 0.84; 'asterisk': 0.84; 'but!': 0.84; "everything's": 0.84; 'one;': 0.84; 'dennis': 0.91 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:to :content-type; bh=52doPVsuIyUX00pzGdPigTPs+TetMk4trXkZid+2pos=; b=tdwQB5Y1LXA2WkFhYaJmoMNXM9p+TpjwRfOPvsSwP+VWwAa2BjdcXYd7bGSpods6ms wBV2EJJBPxFKMAW6UD1BL2QEzQIXy8DvB1Km7SbNlhQGt9kSOIwC6JkhBim+8CtEvKBr A7IzFaN/gCz/O3TY4qN3Cx2CksBYnIzmyavvKBKiZqrFn+XT7zLRrfsACln0wmqsJUQ7 8FdLQMhI+BfC5nn8Sk/tCpEEgw2Kg6ns/h2RnT89zaPtexppWZZ4dEQKJK2dvqaYkGwl 9z9kblwFa4yQQN712v607cGNthX5ePHt/Wr8pq+GqTn67rO1I71eXb9ryptEA7KO4mFx WLng== MIME-Version: 1.0 In-Reply-To: <3jgd381s8te5mq45c2tntu8nih91nk2i5d@invalid.netcom.com> References: <87d32i1ntc.fsf@benfinney.id.au> <5035d3e4$0$1645$c3e8da3$76491128@news.astraweb.com> <50366ec8$0$6574$c3e8da3$5496439d@news.astraweb.com> <3jgd381s8te5mq45c2tntu8nih91nk2i5d@invalid.netcom.com> Date: Fri, 24 Aug 2012 10:01:17 +1000 Subject: Re: Objects in Python From: Chris Angelico To: python-list@python.org Content-Type: text/plain; charset=ISO-8859-1 X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.12 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: 35 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1345766481 news.xs4all.nl 6853 [2001:888:2000:d::a6]:39609 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:27772 On Fri, Aug 24, 2012 at 9:54 AM, Dennis Lee Bieber wrote: > On Fri, 24 Aug 2012 08:00:59 +1000, Chris Angelico > declaimed the following in gmane.comp.python.general: > >> >> But again, that probably doesn't help explain the variables. Unless >> you've come from (or can at least imagine) an environment in which you >> use pointers for *everything*. >> > ... but can not manipulate the pointer directly Right, obviously pointer arithmetic doesn't make sense in Python. But that's (almost) guaranteed by the fact that there is NOTHING you can do with bare integers. foo q = new q; /* note that 'foo' is a typedef that hides the asterisk */ foo w = q +1; /* Pointer arith! Impossible. */ But! foo e = q + one; /* one is the object representing the integer 1 */ This isn't pointer arithmetic. No C compiler will let you add two pointers. You can subtract one from another, but you get back a bare integer, which won't go into a 'foo', so the only thing you could do that would break stuff is: foo r = q + (w - e); /* Syntactically valid */ So you just won't do pointer arith if everything's a pointer. There, I think I just broke a few minds. My task here is done. ChrisA