1

I am working on a long-term project for myself (for now!). I was thinking about designing a graphical console where user can input their python code (within the API of my project) and extend the program. Of course,They can write their own modules and extend it but how can it be implemented as a part of customized GUI? In simple words, I want to take user input IN MY GUI and parse it as python code inside. It is like I want to create small compiler/interpreter for my software.

1 Answer 1

1

You can use Python's exec function to interpret any string as Python code and execute it. For example:

exec('a=4; b=2.5; c=a*b; print c')
Sign up to request clarification or add additional context in comments.

2 Comments

Thanks for short and sweet answer.
No worries, I hope all goes well with your project!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.