[Tutor] Simple Question On A Method (in subclass)

Chris Kavanagh ckava1 at msn.com
Tue Oct 25 14:31:19 CEST 2011



On 10/25/2011 3:50 AM, Dave Angel wrote:
> On 10/25/2011 12:20 AM, Chris Kavanagh wrote:
>>
>>
>> On 10/24/2011 12:06 AM, Marc Tompkins wrote:
>>> On Sun, Oct 23, 2011 at 8:08 PM, Chris Kavanagh <ckava1 at msn.com
>>> <SNIP>
>>
>> My problem was, I wasn't seeing {member} as referring to the class
>> objects {t} and {s}. Since it was, we now can use member just like any
>> class object, and combine it with class functions (and class
>> variables), such as {member.tell}. I had never in my short programming
>> experience, seen an example like this. So I was confused, obviously, LOL.
>>
>
> In the context of:
>
> t = Teacher('Mrs. Shrividya', 40, 30000)
> s = Student('Swaroop', 22, 75)
> members = [t, s]
>
> for member in members;
> member.dosomething()
>
> member does not refer to t and s at all. It refers to the same object as
> t and as s, in succession. members is a list of references to objects.
> Each item in members is bound to a particular object. It is not bound in
> any way to s or t.
>
> For example, suppose we did:
>
> members = [t, s]
> t = 42
> for member in members:
> member.dosomething()
>
> member still references the object holding Mrs. Shrividya, or Swaroop,
> in succession, even though t is now (bound to) an integer (object).
>
>
I understand. . .Thanks for clearing that up for me Dave.
So much to learn, so little time! LOL.
Thanks again to everyone, it's much appreciated.


More information about the Tutor mailing list