print reactive expression: TypeError: __str__ returned non-string (type rx)
I'm on the latest main branch of param. When trying to print a reactive expression it raises an exception
import param
rx_value = param.rx(10)
print(rx_value)
Traceback (most recent call last):
File "/home/jovyan/repos/private/param/script.py", line 3, in <module>
print(rx_value)
TypeError: __str__ returned non-string (type rx)
The workaround is to print rx_value.rx.value instead. But this would be confusing to a lot of users. Please fix.
Hmm. I think it's important that casting an rx expression to a string still returns an rx expression, so that e.g. displaying some result as text or a label in a dashboard can be reactive. So I guess the issue is that the system print function isn't reactive aware? I don't know of a clean way to do it, though maybe mucking around with __builtin__.print could work.
If that's not feasible or too dirty, I guess we could add an .rx.print() method to https://param.holoviz.org/user_guide/Reactive_Expressions.html#special-methods-on-rx , but I'm not sure that would help much, because people then need to figure out to use it.
Any solution I'm missing here?
Duplicate of https://github.com/holoviz/param/issues/939 which I'm closing in favor of this issue as Jim answered here.