[Tutor] How python keeps track of objects
Cameron Simpson
cs at zip.com.au
Mon Nov 24 01:31:33 CET 2014
On 23Nov2014 10:15, Mitch Raful <mitch.raful at gmail.com> wrote:
>Thanks for the replies.
No worries.
>My concern was as the for loop keeps sending
>objects into the do_something() function which uses the same reference name
>other_object and that the previously instantiated other_objected would be
>mutated if the function wasn't finished.
Broadly speaking, each execution of the do_something function has its own
"other_object". There is no collision here. (Imagine how painful programming
would be if this were not the case.) The flip side of that is that the _name_
"other_object" is not available outside the function, and if you use a variable
of that name elsewhere, it too is independent.
Cheers,
Cameron Simpson <cs at zip.com.au>
Fear the government that fears your computer. - Jon Drukman <jsd at gamespot.com>
More information about the Tutor
mailing list