On Sun, May 12, 2013 at 9:02 AM, Alex Ogier <[email protected]> wrote:

> On Sat, May 11, 2013 at 7:55 PM, Russell Keith-Magee <
> [email protected]> wrote:
>
>> I'm sure I understand this argument. Python objects are passed around by
>> reference, not by value, so if you've passed in a Django object deep into
>> another library, that library will be pointing at the same instance. If the
>> instance is changed, everywhere holding a handle to that reference will be
>> updated.
>>
>
> Yes, but that is not what foo = MyObj.objects.get(id=foo.id) does. That
> assigns a new reference to a new object to the name foo. Other references,
> even references to the same instance as foo, are not refreshed. This is
> precisely why a .reload() method is useful -- what is wanted is to mutate
> the instance that is referred to, not to create a new reference and assign
> it to the old name.
>

Understood - I was just using ".get(id=self.id)" as a shorthand for what
the underlying method will effectively be doing. I know the implementation
will be a bit more subtle than that.

Yours,
Russ Magee %-)

-- 
You received this message because you are subscribed to the Google Groups 
"Django developers" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/django-developers?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.


Reply via email to