Skip to content

Instantly share code, notes, and snippets.

@monchier
Created February 28, 2020 18:44
Show Gist options
  • Save monchier/0c2f54864fc1e87e44c2629f21d9d9ef to your computer and use it in GitHub Desktop.
Save monchier/0c2f54864fc1e87e44c2629f21d9d9ef to your computer and use it in GitHub Desktop.
st.cache for mutable state
import streamlit as st
@st.cache(allow_output_mutation=True)
def get_mutable():
return []
x = st.sidebar.slider("Choose x value: ", 0, 10)
mutable_object = get_mutable()
mutable_object.append(x)
st.write(f"Choice history is {mutable_object}")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment