beginners syntax question Thanks

Tony tonyl at homechoice.co.uk
Sat Apr 6 14:59:38 EST 2002


Thanks Chris,

problem solved :)

Tony

Chris Liechti wrote:

> tony clarke <a.clarke11 at ntlworld.com> wrote in
> news:3CAF4E4B.ECE28871 at ntlworld.com:
> 
>> Hi
>> 
>> Try listing the objects  l=["object1','object2'..]
>> then
>> for i in l:
>>  i.update()
> 
> almost, leave away the quotes:
> l=[object1, object2]
>  
>>> I'm trying to call the update() method of several objects ie:
>>>
>>> object1.update()
>>> object2.update()
>>> etc
>>>
>>> I'd really like to do
>>>
>>> for x in range(7):
>>>   "object"+str(x).update
>>>
>>> but can't figure outthe syntax, is this possible?
> 
> yes it is, but there are better ways.
> why are you not storing the objects in a list
> instead of naming them with numbers?
> 
> calling methods on objects in a list is shown above.
> 
> chris
> 




More information about the Python-list mailing list