☰Read-only archive⌕
Looking for help with Bokeh?

This is a read-only archive. Ask questions and join the conversation on GitHub.

Visit Community Support on GitHub →
Archived discussions · Captured October 28, 2026

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

Community Support
Maxxner
Maxxner

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:

⌁   Link to post
Bryan
Bryan

@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).

⌁   Link to post

End of archived discussion · Replies are disabled