On 16/6/2013 3:04 μμ, R. Michael Weylandt wrote:
On Sun, Jun 16, 2013 at 12:06 PM, Ferrous Cranus <supp...@superhost.gr> wrote:
I appreciate you've returned to your Ferrous Cranus persona for this
interchange. It reminds me not to get hung up on concerns of
futility...
On 16/6/2013 1:42 μμ, R. Michael Weylandt wrote:
## CODE SNIPPET##
a = 552315251254
b = a
c = 552315251254
a is b # True _on my machine_
>
> And this pattern continues for any sort of Python object.
>>> a is c # False _on my machine_
And in mine is also True.
>>> id(a)
140160465571760
>>> id(b)
140160465571760
>>> id(c)
140160465571696
Since all object result to point to actual number 6 why don't all of
them (a,b,c) bound to the same memory address.
a and b seem both objects of the same identity, which means they are
both bound to the same memory address(140160465571760)
how come c's memory address is different than a's and b's ?
After all, this is the 3rd object pointing to number 6.
And why not d and e and f and g are all objects of the same memory address?
In fact, b does not go "through" a. The memory address referenced
exists even if the "a" binding is removed using "del a" or some other
mechanism. Imagine this scenario:
[a]
\
6
/
[b]
Using the name "a" or "b" simply tells Python where to look for a
value, but the value itself is not associated with "a" or "b".
If i understood you correctly, you say:
unbounded memory address = value of 6
a = pointer to memory address that holds 6
b = pointer to memory address that holds 6
So, a and b, are two objects(two variable names if you want) that are
bounded to the same memory address. And their value is the address of
unbounded memory address.
Correct?
what id() does, never heard of that function before.
It seems you've also never heard of Python's "help" function?
Try
help(id)
at your interactive prompt and see what happens.
No i had no idea thagt was a bult-in help() function.
So id() is actually the memory address of an object which uniquely
identifies it.
--
What is now proved was at first only imagined!
--
http://mail.python.org/mailman/listinfo/python-list