How to acces the value of a binded function in Python instead of a panel?

According to the documentation, I can use pn.bind(function_name, button):

select = pn.widgets.Select(options=['A', 'B', 'C'])
button = pn.widgets.Button(name='Confirm')

def add(event):
  choice = "You selected" + " " + select.value
  return choice
  

result = pn.bind(add, button)

I can print this result in a Holoviz panel, for example by using pn.Column(select, button, result). However, when I try to access result in Python itself it says <function panel.depends._param_bind.<locals>.wrapped(*wargs, **wkwargs)>. I want to access the string in Python itself, but whatever I tried I can only access some function. I expected to be able to do result.value, but this does not work.

You just needs to put result into pn.Column / pn.Row / pn.panel:

import panel as pn

pn.extension()

select = pn.widgets.Select(options=["A", "B", "C"])
button = pn.widgets.Button(name="Confirm")


def add(event):
    choice = f"You selected {select.value}"
    return choice


result = pn.bind(add, button)
pn.Column(select, button, result)

Wow, that really should be in the documentation.

I think this is a good starting point Add interactivity to a function — Panel v1.2.1

What if I want more things inside a single pn.Column or pn.Row? Can I use a nested pn.Column or pn.Row?

You can put add as many pn.Column / pn.Row as you wants into pn.Column / pn.Row :slight_smile:

OK, so I updated this question many times (I cannot delete it). The solution is, very surprisingly and confusingly, to use result(). Thus if I type result() in python, I get the string in my python code.