Ask coding questions

← Back to all posts
Python Terminal with

Python support for a robot

So, I've been working on a discord bot using python and I was thinking if I could kind of make a little 'Python Interpreter' that's basically

except it uses the Discord chat. So first, I thought this was easy. Right? All I would need to do is add a command to initiate the terminal, store the output into a variable, then end the output into the chat.

Here's my code:

So how this was supposed to work is that you could type in $python exe print("hello, world!") and the bot would print out hello, world!.

but instead, it spat out an error:

(You might have noticed I didn't use exec() or eval() in this code, and that is because Stack Overflow users said not to use it cuz people could do some bad stuff like deleting my python file)

So I have no idea what that means. Is there any way to do this?

Thanks in advance.


from the little research i just performed, literal_eval() just evaluates literals, like "1+1" and "hello" and stuff. i don't know what alternative methods you could use.