Changing the default value of a class property to an instance of the class itself

This is a technical source code question in context of a future PR.

In Bokeh model properties with their default values are stored as class variables. For certain models a property of the model can be an instance of the class itself (see example below).
My question is now, how one would set a default value of this property that isn’t None?
Replacing the None with a constructor call to the respective class (i.e., default=DatetimeTickFormatter()) is invalid in Python. Thus I am wondering if there is an option around this within Bokeh (for the Python as well as JS part)?

Reference example:

@Maxxner the value of default can be a function or lambda that returns a per-instance default value in a deferred fashion. If there is currently a way to accomplish this kind of self-reference, then that would be the route (but I have not personally tried).

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.