I want to have a class and be able to change an object value and have it flow through to methods and objects created in the class. In the below example I am trying have the new value 3 flow through but I keep getting the original value 2. Am I doing it wrong?
class fun:
g=2
def a(c=g):
return c
z=g
fun.g = 3
fun.a()
fun.z
I have searched for __init__ functions but I don't see how they can help here. I tried created a new class making is the same as the fun class. That didn't work either.
gettersandsetters. In python the@propertydecorator is used for this purpose.