Toggle hide/show sidebar from Python

Is there a way to hide/show (toggle) the sidebar from Python?

I am aware that there is initial_sidebar_state in set_page_config (currently beta_set_page_config), but what I would like to do is different.

I want to hide the sidebar from users initially and only show it when “necessary” for the app. My overarching goal is to hide unnecessary complexity from end users (and also nudge the ones who might want / need the complexity about where to find it).


im looking for the Answer