I'm new to Python, and I was wondering why I can't change the attribute for a class instance using a function, if I pass the instance as a function parameter For example, if I had:
class sol:
def __init__(self):
self.val = 0
def fun1(obj, attrib):
obj[attrib] = 1
newSol = sol()
fun1(newSol, "val")
Why can't fun1 change the object attribute? Is there a way to change it, or is the "val" attribute immutable?