title: Validating parameters passed to the constructor method
body: <p>So I've built two classes. One is the Session class which will contain a session's information i.e Time, Date, Venue, session number. The objects created of this class will be used in another class Course. Below is the code for this:</p>
  <pre><code>import csv
  
  
  class Session:
  
      def __init__(self, Time, Date, Venue, Session_Number):
  
          self.Date = Date
          self.Time = Time
          self.Venue = Venue
          self.Session_Number = Session_Number
          self.students_lst = []
  
          with open(&quot;Sessions_Info.csv&quot;, &quot;a&quot;, newline=&quot;&quot;) as info_file:
              csv_writer = csv.writer(info_file, delimiter=&quot;,&quot;)
              csv_writer.writerow([self.Time, self.Date, self.Venue, self.Session_Number])
  
      def add_students(self, lst):
          for student in lst:
              self.students_lst.append(student)
  
  
  class Course:
  
      def __init__(self, course_title, course_instructor):
          self.course_title = course_title
          self.course_instructor = course_instructor
          self.sessions_lst = []
          self.students_enrolled = []
  
      def enroll_students(self, lst):
          for student in lst:
              self.students_enrolled.append(student)
  
      def create_sessions(self, session):
          self.sessions_lst.append(session)
  </code></pre>
  <p>I need to validate the parameters passed to the constructor method of the Session Class when the create_sessions method of the Course class is called so that no two sessions with the same session number are created and I also need to make sure that no two sessions with the same venue and time get created.
  I've tried reading from the csv file in the constructor method as it would contain all information of the previous sessions created and using 'assert' but that didn't work.</p>
  <p>Is there a way to pull this off in the constructor method?</p>