0

I am currently working on a IDE /text editor coded in python and would like to add the option to run the code written by the user in a similar way to how it is displayed with IDLE. I have been trying out subprocess and os as well as the exec() function but cannot find a way to print the output or error when the code doesn't work.

If anyone knows a way to do this it would be immensely helpful.

mybrave
  • 1,662
  • 3
  • 20
  • 37
TheFluffDragon9
  • 514
  • 5
  • 11
  • 1
    Many interactive environments like that use a [REPL](https://en.wikipedia.org/wiki/Read%E2%80%93eval%E2%80%93print_loop) design – Cory Kramer Apr 17 '20 at 11:04
  • You can try to use Visual Studio Code. You are able to edit / debug and see the result in inbuilt console. https://code.visualstudio.com/docs/languages/python – mybrave Apr 17 '20 at 11:04
  • @mybrave I think you missed the mark here, TheFluffDragon9 is trying to implement their own IDE, they are not looking for an off-the-shelf one. – Cory Kramer Apr 17 '20 at 11:06
  • 1
    https://medium.com/centrality/building-repls-for-fun-and-profit-597ae4fcdd85 might have some useful info – Tom Dalton Apr 17 '20 at 11:07
  • You are right. I was too quick and haven't read fully the question. @TheFluffDragon9 may have a look how MS is implementing this. I think VS code is open source :) https://github.com/Microsoft/vscode – mybrave Apr 17 '20 at 11:09
  • Thank you very much for all of the information on REPLs, this is very useful :) – TheFluffDragon9 Apr 17 '20 at 11:16
  • Using InteractiveConsole or InteractiveInterpretter, the output of the code being run is always printed to IDLE's shell. Does anyone know if there is a way to store the output in a variable / write to a file / insert into tkinter text widget or otherwise get the output? – TheFluffDragon9 Apr 17 '20 at 11:39

0 Answers0