Dave thank you for your patience. It really is appreciated.
In the interest of closing this thread I'm posting the final version
that works, and achieves the goal of showing how to represent data
both in a list and in an object:
#
# Example to show the difference between list data and object data
#
class Qb:
def __init__(self, first_name='', last_name='', phone='',
email='', stadium=''):
self.first_name = first_name
self.last_name = last_name
self.phone = phone
self.email = email
self.stadium = stadium
Qb_list = [["Joe", "Montana", "415-123-4567",
"[email protected]","Candlestick Park"],
["Fran", "Tarkington","651-321-7657",
"[email protected]", "Metropolitan Stadidum"],
["Joe", "Namath", "212-222-7777", "[email protected]", "Shea Stadium"],
["John", "Elway", "303-9876-333", "[email protected]", "Mile
High Stadium"],
["Archie", "Manning", "504-888-1234", "[email protected]",
"Louisiana Superdome"],
["Roger", "Staubach", "214-765-8989", "[email protected]",
"Cowboy Stadium"]]
quarterbacks = [] # Create an empty object list
len_Qb_list = len(Qb_list) # Get the lenght of the list of
lists which is the
# number of rows in the input data
for i in range(0, len_Qb_list): # Iterate for the number of rows
nq = Qb(*Qb_list[i]) # Create an instance of class Qb called "nq"
# and populate each field
quarterbacks.append(nq) # Append an instance of object
"nq" into object list "quarterbacks"
i = i + 1 # Iterate for each row in "Qb_list"
print (quarterbacks[3].phone) # Print an item from the object
list "quarterbacks"
print (Qb_list[3][2]) # Print the same object from the
original list of lists
--
Frank L. "Cranky Frankie" Palmeri
_______________________________________________
Tutor maillist - [email protected]
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor