Session_state does not seem to be working in the cloud

Hi Randy,

Have you confirmed that you are using the same version of Streamlit both locally and on Cloud?

That is indeed part of the explanation.
Being new to Streamlit, I installed it with a Conda install. I noticed (a few days later) that the version it installed was 0.84.
So indeed, the version I was running locally was 0.84 and the one online is currently 1.5.0 (1.5.1 locally).
That explains the difference I noticed in the behaviour of st.session_state between 0.84 locally and 1.5.0 in the cloud. Strangely enough, what I wanted to achieve (widget state preservation) worked on 0.84 but not on 1.5.0 . That was the origin of my confusion.

While st.session_state.update(st.session_state) might work, this is the first time I’ve ever seen that used, so I would not expect this to be the actual answer.

Well, the fact remains that the code snippet in my first post does not preserve widget states.
After adding the command st.session_state.update(st.session_state) widget states are preserved.
I hope you can understand my confusion because this command is pointless in a pure Python environment, yet it seems to make a lot of difference in a Streamlit environment.
I am new to Streamlit so I probably missed a lot of the history of the Streamlit development, but I think it is very important that users are informed that some Pythonic statements can behave un-Pythonic.
Or otherwise put, Streamlit does some things ‘under the hood’ that go against the normal behaviour of Python code. Or atleast, have some side effects that are surprising if you do not know about them.

@okld and I had some discussion about this in thread: