On Tue, Sep 11, 2012 at 10:23 PM, Ashley Fowler <afowl...@broncos.uncfsu.edu > wrote:
> 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 > variables. > > 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 dict. 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 file. 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. -- Best Regards, David Hutto *CEO:* *http://www.hitwebdevelopment.com*
_______________________________________________ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor