[Tutor] Constructing a object
dwightdhutto at gmail.com
Wed Sep 12 06:30:01 CEST 2012
On Tue, Sep 11, 2012 at 10:23 PM, Ashley Fowler <afowler2 at broncos.uncfsu.edu
> How do you construct a object using variables?
> For instance I have to construct a student object, by first prompting
> the user to enter variables for the Student class (their first and last
> names, credits and gpa) then construct a Student object using those
> First you want to collect the variables from the user, like so:
>>> student_first_name = raw_input("Enter First Name: ")
Enter First Name: David
Then I would init the class with these variable, and return a tuple, or
If I'm getting the question you're asking correctly. Except I'd just use a
function to call(instead of a class, but this might be the assignment given
to you), and collect it there, then write the data to a db, or a custom db
Or you could call the class without init, then go through the input in
different functions by defining them as self.first_name = raw_input("Enter
First Name: "), collect those into a return value, and pass them through
another function/class that inserted the data into a db.
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the Tutor