Ask coding questions

← Back to all posts
Python tkinter problem
ia13ru (43)

I am trying to make the code beneath shorter.

class Thing:
#insert class here

from tkinter import *
#insert setup code here
#this is where the code I want to shorten starts
object0.function()
object1.function()
object2.function()
#etc.

I want to do something like this:

for i in range(5):
   vars('object'+str(i))['function()']

However, it returns an error.
What am I doing wrong?