creating and naming objects

Brian bnblazer at gmail.com
Wed Jun 7 13:07:52 EDT 2006


Thank you all for your response.  I think that I am getting it.  Based
on those responses, would I be correct in thinking that this would be
the way to initialize my Student object and return the values?

class Student:
    def __init__(self, name, id):
        self.name = name
        self.id = id

    def getName(self):
        return self.name

    def getId(self):
        return self.id

Additionally, correct me if I am wrong but I can recycle:

foo = Student()

And doing so will just create a new instance of Student (with whatever
attributes it is given) and the original foo is gone?

Thanks for your help and patience.  After reading my original post and
then this one, I could see that it may look suspiciously like a home
work assignment.  Trust me it's not.  The student example just seemed
like a good fit to discuss this.

Thanks again,
Brian




More information about the Python-list mailing list