Is there a way to call a function every time the value of a variable changes in python?
Something like a listener, maybe?
In particular, I mean the case when only a variable is available . between scripts such as GAE-Session. (Which uses cookies, memcache, etc. to exchange data)
Example: ScriptA and ScriptB share a session variable. When Script B modifies it, SctiptA must call a method to handle this change.
. .
class Something(object): @property def some_value(self): return self._actual @some_value.setter def some_value(self, value): print "some_value changed to", value self._actual = value
, __setattr__ .
__setattr__
.
( , )
def set_myvar(x): my_var = x some_function() return my_var
, "int" "float" "setattr", -.
class MyInt(int): ... def __setattr__(self, attr, val): ... super(MyInt, self).__setattr__(attr, val) ... var = MyInt(5)
Source: https://habr.com/ru/post/1606325/More articles:Errors in Ember-Data when using findAll () function - javascriptWoocommerce - Alternative for woocommerce_locate_template - phpApple Music Genre Templates / Bubbles - ioshttps://translate.googleusercontent.com/translate_c?depth=1&pto=aue&rurl=translate.google.com&sl=ru&sp=nmt4&tl=en&u=https://fooobar.com/questions/1606323/add-constraints-to-typealiases-inside-swift-protocols&usg=ALkJrhiN11545HdGQNY2c_B5OUFpbhLVswHow to check if the value of a variable has changed - variablesIs 100% height a few pixels from the page? - htmlFast class extension only according to protocol - iosSQL Server to display all columns, but with separate values in one of the columns (without grouping anything) - sql-serverWhat is the common cause of a range outside the buffer bounds in WebGL - webglКак проверить нулевое состояние в Data weaver: Mule - muleAll Articles