-
-
Notifications
You must be signed in to change notification settings - Fork 74
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Cannot change instance attributes with a Callable without passing in parameterized class #900
Comments
Thanks for the good question! I've updated the issue title to indicate that it's not class attributes that are being updated, it's instance attributes, even though they are declared at the class level in the source code. (I.e. the action here updates In any case, I agree that typing |
An alternative could be to set it inside import param
class ExpEnv(param.Parameterized):
url_input = param.String("test")
url_list = param.List([])
url_submit = param.Action()
def __init__(self, **params):
super().__init__(**params)
self.url_submit = lambda *a: self.url_list.append(self.url_input) or self.param.trigger('url_list')
ee = ExpEnv()
ee.url_submit() I have added |
That would make some code reviewers very unhappy 😄 |
Problem:
Param callables do not work as expected given the purpose of the parametrized class.
Per the documentation, the purpose of the callables is partly to modify the attributes of the class.
Instead of having to pass
self
to the instance like sooutput:
['test']
it would be preferable to simply call the
test_class.fn()
where it implicitly passesself
within the parameter creation like so:This makes more sense, given that the intent of the callable is to modify the attributes of the instance.
Additional context
Discourse discussion: https://discourse.holoviz.org/t/how-does-param-action-callable-handle-passing-self-to-function-unexpected-behavior-in-conjunction-with-panel/6665
The text was updated successfully, but these errors were encountered: