On Sun, Jun 16, 2013 at 10:59 AM, Nick the Gr33k <supp...@superhost.gr> wrote: > On 16/6/2013 12:22 μμ, Denis McMahon wrote: >> >> For example, in Python >> >> a = 6 >> b = a >> c = 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 which > 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 = 6; b = a; c = 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 = 552315251254 b = a c = 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 = a variable that has as a value a memory address a variable = >>> 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 -- http://mail.python.org/mailman/listinfo/python-list