Is it possible for the user to input a Python snippet and run it? Like this:

x = raw_input("Python snippet: ") #And then run the script typed in here

Also, we know how errors happen all the time. Is it possible to make it so that when errors happen because there was something invalid inputted into a raw_input (or otherwise any inputting function), a print function pops up and defines the error?

Recommended Answers

All 4 Replies

See the exec and eval functions.

What about the error one?

See try...except.,else...finaly for error handling.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.