Python Forum
Python classes and init method
Thread Rating:
  • 1 Vote(s) - 5 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Python classes and init method
#1
Hi, I have to create  a Request class with suitable attributes to hold the request Id, password, name (first and surname), programme, year of study, campus location, module name and a list of available days (Monday …Sunday) and timeslots (morning, afternoon, evening). The user must be able to enter as many unique timeslots as they wish on a single request. I also have to use the __init method to accept a request ID passed from the calling object and allow the user to input the values for the other attributes. 

This is what I have so far...
class Request:

    def __init__(self, request_id, password, name, programme, year_of_study, campus_location, module_name,list_of_available_days):

        # This is creating methods within a class, and  defining what arguments we want to accept
        self.request_id = request_id  # Here I am setting the variables for the instance
        self.password = password
        self.name = name
        self.programme = programme
        self.year_of_study = year_of_study
        self.campus_location = campus_location
        self.module_name = module_name
        self.list_of_available_days = list_of_available_days
The problem is I don't know how to get user inputs like for example the request_id and so on. How do I go about doing that? Any help would be very much appreciated thank you.
Reply


Messages In This Thread
Python classes and init method - by Alaweey98 - Apr-02-2017, 06:58 PM
RE: Python classes and init method - by ichabod801 - Apr-02-2017, 07:28 PM
RE: Python classes and init method - by Alaweey98 - Apr-02-2017, 07:35 PM
RE: Python classes and init method - by ichabod801 - Apr-02-2017, 07:36 PM
RE: Python classes and init method - by Alaweey98 - Apr-02-2017, 07:44 PM
RE: Python classes and init method - by wavic - Apr-02-2017, 07:57 PM
RE: Python classes and init method - by Alaweey98 - Apr-02-2017, 08:03 PM
RE: Python classes and init method - by wavic - Apr-02-2017, 08:15 PM
RE: Python classes and init method - by ichabod801 - Apr-02-2017, 10:32 PM
RE: Python classes and init method - by wavic - Apr-03-2017, 12:02 AM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Python networking vs classes blackknite 4 2,955 Oct-15-2018, 02:44 PM
Last Post: blackknite

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020