I have a class with several attributes:
class Fighter():
def __init__(self, name = "", gender = "", age = 0, weight = 0, win = 0, loss = 0, ko = 0, date = ""):
self.__name = name
self.__age = age
self.__weight = weight
self.__win = win
self.__loss = loss
self.__ko = ko
self.__date = date
From the user end of my program, an object is created and stored in a list using the following lines in a loop:
s = Fighter(name, gender, age, weight, wins, losses, ko, time)
collection.append(s)
I am able to sort this list by a number of attributes, such as name, weight, etc. and that works perfectly. I also have instance methods inside the class that return the value of a specific attribute, such as:
def fighter_age(self):
return str(self.__age)
My question is, how do I print this information as an organized table, with a column for each attribute, such as:
-----------------------------------------------------------------------
|Fighter Number|Name |Age |Weight |Wins|Losses|Date Added |
|1 |Anderson Silva|39 |185 |33 | 6 |2014-01-17 |