Using Inheritance: - Let's Build An Application That Organizes Info About People!
Using Inheritance: - Let's Build An Application That Organizes Info About People!
Building a class
import datetime class Person(object): def __init__(self, name): """create a person called name""" self.name = name self.birthday = None self.lastName = name.split(' ')[-1] def getLastName(self): """return self's last name""" return self.lastName # other methods def __str__(self): """return self's name""" return self.name
def __lt__(self, other): """return True if self's ame is lexicographically less than other's name, and False otherwise""" if self.lastName == other.lastName: return self.name < other.name return self.lastName < other.lastName # other methods def __str__(self): """return self's name""" return self.name