Question
class PersonList(Sortable, Searchable, list): This class has no instance variables. The list data is held in the parent list class object. The constructor must
class PersonList(Sortable, Searchable, list):
"""
This class has no instance variables.
The list data is held in the parent list class object.
The constructor must call the list constructor:
See how this was done in the Tower class.
Code a populate method, which reads the CSV file.
It must use: try / except, csv.reader,
and with open code constructs.
Code the sort method: Must accept a function object
and call the function.
Code the search method: Must accept a function object
and a search item Person object and call the function.
Code a __str__ method: Look at the Tower class for help
You may want to code a person_at method for debug purposes.
This takes an index and returns the Person at that location.
"""
def __init__(self):
list.__init__(list())
def person_at(self,index:int):
return
def populate(self,filename:str):
with open(filename) as csvfile:
reader = csv.reader(csvfile, delimiter = ",")
for row in reader:
super().append(Person(row[0],row[1],row[2],row[3]))
def sort(self,func:'func_object'):
super().sort(func)
def search(self,func:'func_object',person_obj:'Person'):
super().search(func,person_obj)
def __str__(self):
return
Python help me write __str__ method and person_at method
how do i call objects out of a list inherent class
Person is an object inside of the Personlist class
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started