How do I update a variable value across modules Python? -
i have main script , importing module class in it. when instantiate class 1 of arguments y
, therefore have equivalent self.y = y
in __init__
method. problem in main script have for
loop changes y
value , calls method 'live_plotting' same class. have pass in y
value argument again , have self.y = y
inside method. not neat, there way of updating self.y
across modules without having pass in argument again? thought of using pointers apparently pointer in python. can offer alternative solution?
i'm not sure if it's want, understanding want update value of self.y without method?
this done executing
object_name.y = new_value
where object_name
name gave instance of class, seeing self variables declared in __init__
attributes belong instance of class.
Comments
Post a Comment