[Tutor] Help with my program
Kenny Shen
littlemog at gmail.com
Fri Oct 23 05:59:29 CEST 2009
Hi tanner,
I suppose the following is possible:
class A:
def __init__(self):
self.height = 1
self.weight = 7
self.name = "tanner"
self.grade = "A"
def getinfo(self):
info = []
info.append(self.name)
info.append(self.weight)
info.append(self.height)
info.append(self.grade)
return info
class B:
def __init__(self, a):
self.info = a.getinfo()
print self.info
a = A()
b = B(a)
Thanks,
Kenny
On Fri, Oct 23, 2009 at 9:59 AM, tanner barnes <tanner989 at hotmail.com>wrote:
> Ok so im in need of some help! I have a program with 2 classes and in one
> 4 variables are created (their name, height, weight, and grade). What im
> trying to make happen is to get the variables from the first class and use
> them in the second class.
>
> ------------------------------
> Windows 7: It helps you do more. Explore Windows 7.<http://www.microsoft.com/Windows/windows-7/default.aspx?ocid=PID24727::T:WLMTAGL:ON:WL:en-US:WWL_WIN_evergreen3:102009>
>
> --
> http://mail.python.org/mailman/listinfo/python-list
>
>
--
-
"A mental model is good. I change mine all the time."
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/tutor/attachments/20091023/b9c6fb1f/attachment.htm>
More information about the Tutor
mailing list