Newbie: List of instances?
Susan Williams
susan at mars.provis.com
Fri Mar 29 16:17:17 EST 2002
>> This is closer. a itself is an object, and the way you deal
>> with it, at least for some functions, is thru its methods.
>> append is a method of the list object, so what you really want
>> is:
>>
>> a.append(Bob('localhost'))
>
>This works! If I create a list a that has five elements where
>are just instances of Bob, can I "call" a method for a specific
>element of the list? I take I can (Jeff sneaks off to experiment
>while his wife is napping).
>
>Thanks!
>
>Jeff
Hope your experiments went well. Not sure exactly which question
you're asking, but:
Once you have a list with elements, you can get to an element
in the "normal" way like a[0]. This is really using a method
of the list object too, but its more like a function overload
where [] is a sort of operator. (Sorry, I'm not a "language
lawyer" so that is not the best explanation :-)
Or: yeah, you can call a Bob method on an element of a:
a[0].Bobmethod1('somethingOrOther')
susan
More information about the Python-list
mailing list