How to access a Bokeh object by its name in complex layouts

I am building an interface with a complex layout (e.g. multiple rows and columns) and I am trying to figure out a way of simplifying the access to a given object (be it a figure, widget etc) through its name. Let’s take the following example:

import numpy as np

from bokeh.plotting import figure, show
from import output_notebook
from bokeh.layouts import row, column
from bokeh.palettes import Category20

x = np.random.randint(1,10,10)
y = np.random.randint(1,10,10)

p1 = figure()
p2 = figure()
p3 = figure(title='Me!', name='target')

c = column([p2,p3])
r = row(p1,c)

Is there a way to access p3 from the main layout object r ? I understand that for the provided example it is possible to use the variable name directly, but my app contains plots that are plotted in sub-functions. I could return the handle of each plot individually, but I was wondering if there was a method to search “multi-dimensional” (i.e. navigating through the children) layouts by properties. I tried using'target')) , but this returns and object I am not sure how to use:

<generator object find.<locals>.<genexpr> at 0x100e2cc00>


Answered here:

In future, please include the link as well if you decide to crosspost.

Of course - sorry