python - Python3 - Iterate over object methods with similar names -


i trying iterate list of object methods similar names. there clever way can this. have objects similar use iterator instead of making list of functions.

dog1.feed() dog2.feed() dog3.feed() dog4.feed() dog5.feed() ... 

all local object names in locals():

for in range(1,6):     locals()["dog" + str(i)].feed() 

Comments

Popular posts from this blog

android - MPAndroidChart - How to add Annotations or images to the chart -

javascript - Add class to another page attribute using URL id - Jquery -

firefox - Where is 'webgl.osmesalib' parameter? -