Skip to content

Cannot change instance attributes with a Callable without passing in parameterized class #900

Open
@DmitriyLeybel

Description

@DmitriyLeybel

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.

Invocation parameters are a loose group of types that either contain an executable (callable) object, are invoked to execute some other code, or are set to change the value of some other parameter(s) or attribute(s).

Instead of having to pass self to the instance like so

class ExpEnv(param.Parameterized):
  url_input = param.String('test')
  url_list = param.List([])
  url_submit = param.Action(lambda self: self.url_list.append(self.url_input))

ee = ExpEnv()
ee.url_submit(ee)
ee.url_list

output: ['test']

it would be preferable to simply call the test_class.fn() where it implicitly passes self within the parameter creation like so:

ee.url_submit()

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions