okld/streamlit-ace

Is there a way to print the output of the code defined in value?

conceptofmind opened this issue · 1 comments

Hi,

I am relatively new to Streamlit. I was wondering if it was possible to automatically print the output of the code defined in the value parameter.

content = st_ace(
    value = """a = 2 \n b = 3 \n c = a + b \n print(c)""",
    placeholder=" a = 2",
    language='python',
    theme='dracula',
    show_print_margin=True,
    auto_update=True
)

# Display editor's content as you type
content

I would want to print the output of c to the Streamlit app. Is there a specific way I should be defining this?

Any input would be gretaly appreciated.

Thank you for your time,

Henry

okld commented

Hello @conceptofmind, you can do exec(content) to execute ace's content.