Path: csiph.com!usenet.pasdenom.info!news.albasani.net!newsfeed.freenet.ag!news2.euro.net!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.001 X-Spam-Evidence: '*H*': 1.00; '*S*': 0.00; 'python.': 0.02; '16,': 0.03; 'charset:iso-8859-7': 0.04; 'cpython': 0.05; 'indicating': 0.07; 'memory.': 0.07; 'facts': 0.09; 'terms,': 0.09; 'variable,': 0.09; 'cc:addr:python-list': 0.11; 'python': 0.11; 'changes': 0.15; '"is"': 0.16; '10:59': 0.16; 'language)': 0.16; 'nick': 0.16; 'operator.': 0.16; 'variable.': 0.16; 'language': 0.16; 'wrote:': 0.18; 'variable': 0.18; 'bit': 0.19; 'examples': 0.20; 'written': 0.21; '(the': 0.22; '>>>': 0.22; 'memory': 0.22; 'cc:addr:python.org': 0.22; "aren't": 0.24; 'lets': 0.24; 'pointer': 0.24; 'cc:2**0': 0.24; 'compare': 0.26; 'header:In- Reply-To:1': 0.27; 'point': 0.28; 'michael': 0.29; 'am,': 0.29; 'points': 0.29; 'message-id:@mail.gmail.com': 0.30; 'code': 0.31; 'too.': 0.31; 'behaving': 0.31; 'terms.': 0.31; 'actual': 0.34; 'could': 0.34; 'common': 0.35; 'but': 0.35; 'received:google.com': 0.35; 'really': 0.36; 'false': 0.36; 'example,': 0.37; 'two': 0.37; 'that,': 0.38; 'anything': 0.39; 'most': 0.60; 'address': 0.63; 'different': 0.65; 'here': 0.66; 'between': 0.67; 'believe': 0.68; 'detail.': 0.68; 'subject': 0.69; 'below.': 0.71; 'guaranteed': 0.75; 'actually,': 0.84; 'democracy': 0.84; 'subject:gets': 0.84; 'to:addr:support': 0.84; 'same,': 0.91; '2013': 0.98 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc:content-type:content-transfer-encoding; bh=OfXzBJPyDh4P0wX/HYoatyF0RmpQG9fQ4w7FsyMceCY=; b=AtQGYuE2kVPYKy8OfxQQGEoWPj53f72mOSuwfGDoOvUc79ulXGfleOsj6KGZqenWJE nTLD5HgyDtkKcquPxAD/nMy8ZZh/dOCTlb20Msff3zMcv1RxDXFT0zE+V/QVI/vS+6XK TU7/aaB+M8t0PBUbGr8cyiX4KuX0nsXtA+8r+pSteqbKXipkYIGQZhvzT2h74wo9tBfw 8UYCz61Fdi3i/0n4EsnKNOB5mz4pp7ptwt40U/Ks1BiQ2v353M2jg/ZaqTXZTjSw3U2x 99RFFgxjCuiJYtm1ULQAh72rH00dfYaE+3FrU+ql4z5oIunPvbzW9phYSKzomtWh99rH AT+Q== X-Received: by 10.112.16.105 with SMTP id f9mr4280982lbd.69.1371379377853; Sun, 16 Jun 2013 03:42:57 -0700 (PDT) MIME-Version: 1.0 In-Reply-To: References: <2bc90d3b-09c2-4315-9357-ff7f039465e0@googlegroups.com> <51b926a3$0$29997$c3e8da3$5496439d@news.astraweb.com> <51ba6e92$0$29997$c3e8da3$5496439d@news.astraweb.com> <51bb454c$0$29997$c3e8da3$5496439d@news.astraweb.com> From: "R. Michael Weylandt" Date: Sun, 16 Jun 2013 11:42:36 +0100 Subject: Re: A certainl part of an if() structure never gets executed. To: Nick the Gr33k Content-Type: text/plain; charset=ISO-8859-7 Content-Transfer-Encoding: quoted-printable Cc: python-list 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: 91 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1371379385 news.xs4all.nl 15934 [2001:888:2000:d::a6]:34784 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:48429 On Sun, Jun 16, 2013 at 10:59 AM, Nick the Gr33k wro= te: > On 16/6/2013 12:22 =EC=EC, Denis McMahon wrote: >> >> For example, in Python >> >> a =3D 6 >> b =3D a >> c =3D 6 >> >> a and b point to one memory location that contains the value 6 >> c points to a different memory location that contains the value 6 > > > I believe you are mistaken. > > a here is not a pointer but variable, > which is a memory location that stores value 6. > > b here is a pointer. It's value is the memory location of variable a whic= h > stores value 6. > > c here is just te same as a , a variable. Actually, y'all both might be. This is a bit CPython specific and not mandated by the language specification. To Nikos: please don't extrapolate from the examples below. They are a CPython (the most common implementation of the Python language) specific detail. ## CODE SNIPPET## a =3D 6; b =3D a; c =3D 6 id(a) id(b) id(c) ## END CODE## These are all the same, indicating that they all point to the "same 6" in memory. That's a CPython specific optimization (caching small integers) which is not guaranteed by the language and changes between pythons and between compiles. For example, ## CODE SNIPPET## a =3D 552315251254 b =3D a c =3D 552315251254 a is b # True _on my machine_ a is c # False _on my machine_ id(a) id(b) id(c) ## END CODE## Note that to compare if two names point to the same "object, you can use the "is" operator. a is b c is a etc. > >>> A pointer =3D a variable that has as a value a memory address a variabl= e =3D >>> a memory address that has as a value the actual value we want to store. >> >> >> These are really C terms, not Python terms. Stop thinking that C is >> behaving like Python. > > > > I think it behaves the same way, but lets here from someone else too. I understand the Greeks invented democracy and all that, but facts aren't subject to it. > > Whats the difference of "interpreting " to "compiling" ? If only it could be googled.... Alas, no one has ever written anything about technology on the internet. Ironic that... Michael