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 <cka...@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).
--
DaveA
_______________________________________________
Tutor maillist - Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor