[Tutor] basic class loading question
Cranky Frankie
cranky.frankie at gmail.com
Tue Nov 22 18:09:53 CET 2011
On Tue, Nov 22, 2011 at 11:26 AM, Dave Angel <d at davea.name> wrote:
snip
> quarterbacks = []
> for ....
> quarterbacks.append( )
>
>
> Now that you really have a list, then you can print a particular one with:
>
> print (quarterbacks[2].last_name)
Dave I'm sorry but I just don't get this. I have virtually no
experience with classes.
What seems like it shoud work is this:
#######################
len_Qb_list = len(Qb_list)
for i in range(0, len_Qb_list):
quarterbacks = Qb(*Qb_list[i])
i = i + 1
print (quarterbacks[2].last_name)
############################
In other words, define an instance of the Qb class called
quarterbacks, and then "load" or instantiate instances of the class
using the 6 sets of values from Qb_list.
My error message is:
Traceback (most recent call last):
File "D:/Python31/q", line 27, in <module>
print (quarterbacks[2].last_name)
TypeError: 'Qb' object does not support indexing
--
Frank L. "Cranky Frankie" Palmeri
Risible Riding Raconteur & Writer
“How you do anything is how you do everything.”
- from Alabama Crimson Tide training room
More information about the Tutor
mailing list