I have a question that some may consider silly, but it has me a bit
stuck and I would appreciate some help in understanding what is going
on.
For example, lets say that I have a class that creates a student
object.
Class Student:
def setName(self, name)
self.name = name
def
def createStudent():
foo = Student()
/add stuff
Now, suppose that I want to create another Student. Do I need
to name that Student something other than foo? What happens
to the original object?
If you want to keep the old student around, you have to keep a
reference to it
Brian wrote:
I have a question that some may consider silly, but it has me a bit
stuck and I would appreciate some help in understanding what is going
on.
For example, lets say that I have a class that creates a student
object.
Class Student:
def setName(self, name)
Brian wrote:
[...]
For example, lets say that I have a class that creates a student
object.
Class Student:
def setName(self, name)
self.name = name
def setId(self, id)
self.id = id
Then I instantiate that object in a method:
def createStudent():
foo =
Brian wrote:
I have a question that some may consider silly, but it has me a bit
stuck and I would appreciate some help in understanding what is going
on.
For example, lets say that I have a class that creates a student
object.
Class Student:
def setName(self, name)
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 =
Brian wrote:
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
Brian wrote:
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:
Do yourself a favour: use new-style classes
class
In article [EMAIL PROTECTED],
Brian [EMAIL PROTECTED] wrote:
I have a question that some may consider silly, but it has me a bit
stuck and I would appreciate some help in understanding what is going
on.
For example, lets say that I have a class that creates a student
object.
Class
Maarten van Veen wrote:
snip
Hi Brian,
If you would do it like this:
Class Student:
def setName(self, name)
self.name = name
def setId(self, id)
self.id = id
def createStudent():
foo = Student()
foo.setName(Brian)
foo = Student()
print
10 matches
Mail list logo