How exactly does streamlit loop through things?

If Streamlit is used in a class, and the class was called in a different script, which script does Streamlit loop through? The separate script only sets things up and does not directly use Streamlit. What type of behavior should I expect upon automatic refresh? Will it recreate its own class object, or will it re-run both scripts and reinitialize everything?

Hey @Gilnore, welcome to our forum :balloon:

You generally can think of streamlit as any other python library - and should not expect a different behaviour when factoring calls into other classes or modules as you would with any other python library.

Do you have a use-case/example in mind with mock code? I think that would be helpful!

# utils/objects.py

import streamlit as st 

class MyClass:
    def __init__(self):
        return "foo"

    def do_something_with_streamlit(self):
        st.balloons()

My app:

# streamlit_app.py

from utils.objects import MyClass

instance = MyClass()

instance.do_something_with_streamlit()  # <- this will print balloons

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.