So I have such sample code. As you can see locale setted twice. However I keep getting error:
AttributeError: st.session_state has no attribute “locale”. Did you forget to initialize it? More info: Add statefulness to apps - Streamlit Docs
What is wrong here?
import streamlit as st from dataclasses import dataclass @dataclass class Locale: ai_role_prefix: str # --- LOCALE SETTINGS --- en = Locale( ai_role_prefix="base", ) if 'locale' not in st.session_state: st.session_state.locale = en if __name__ == "__main__": st.session_state.locale = en print(st.session_state.locale.ai_role_prefix)