from datetime import datetime as dt class Employee: def __init__(self, first, last, date_of_birth): console.warn(f"__init__('{first}', '{last}', {date_of_birth})") self.first = first self.last = last self.date_of_birth = date_of_birth def __str__(self): console.warn('__str__()') return f"Full Name: {self.first} {self.last}, Date of birth: {self.date_of_birth:%Y-%m-%d}" @property def first(self): console.warn(f"property(getter): first('{self._first}')") return self._first @property def last(self): console.warn(f"property(getter): last('{self._last}')") return self._last @property def date_of_birth(self): console.warn(f"property(getter): date_of_birth({self._date_of_birth})") return self._date_of_birth @first.setter def first(self, first): console.warn(f"property(setter): first('{first}')") if not first: raise ValueError('Missing first name') self._first = first @last.setter def last(self, last): console.warn(f"property(setter): last('{last}')") if not last: raise ValueError('Missing last name') self._last = last @date_of_birth.setter def date_of_birth(self, date_of_birth): console.warn(f"property(setter): date_of_birth({date_of_birth})") if not date_of_birth: raise ValueError('Missing date of birth') try: self._date_of_birth = dt.strptime(date_of_birth, '%Y-%m-%d').date() except: raise ValueError('Invalid date of birth') def get_employee(): console.warn('get_employee()') first = input(); print(f"First name: {first}") last = input(); print(f"Last name: {last}") date_of_birth = input() # yyyy-mm-dd print(f"Date of birth: {date_of_birth}") return Employee(first, last, date_of_birth) # return class employee = get_employee() # get class print(employee)