I know how I can loop over all variables of a class, but what if I just want to loop over some of them?
class MyClass:
def __init__(self,var1,var2,var3,var4):
self.var1 = "foo"
self.var2 = "bar"
self.var3 = "spam"
self.var4 = "eggs"
items_to_loop = ("var2","var4")
for item in items_to_loop:
print(item, MyClass.(item))
Doesn't work. How do I do this?