Linked Questions

1 vote
2 answers
4k views

I am writing a python script which contains a list containing python print statements as a string. In my function, I am using a for loop to run exec function to run those statements. Here is my ...
sshussain270's user avatar
  • 1,885
0 votes
2 answers
871 views

Hey I have been messing around on Python and I need to know if there is a way of testing if the output of a Python Script equals something. Heres what I have been trying: a = """ print("Hey") b = 5 ...
Digbywood's user avatar
0 votes
0 answers
203 views

I have recently been building a discord bot that is, apart from being a small IDE, trains and teaches you Python, by asking you questions about it. But I am stuck on the IDE part. The problem is that ...
Rodion Zuban's user avatar
60 votes
11 answers
72k views

For testing purposes I want to directly execute a function defined inside of another function. I can get to the code object of the child function, through the code (func_code) of the parent function, ...
user2433423's user avatar
9 votes
1 answer
6k views

What's a good way to exec a bunch of python code, like exec mycode, and capture everything it prints to stdout into a string?
Claudiu's user avatar
  • 231k
5 votes
3 answers
5k views

How can I run a multi-line string of code from inside python, additionally the string is generated at runtime and stored in either a string or an array. Background I have a function which ...
Murchie85's user avatar
  • 855
5 votes
4 answers
432 views

I've one helper script which I want to call from main script which is acting as a Server. This main script looks like this: Class Stuff(): def __init__(self, f): self.f = f self....
Khatri's user avatar
  • 656
7 votes
4 answers
962 views

Is there any way to write both commands and their output to an external file? Let's say I have a script outtest.py : import random from statistics import median, mean d = [random.random()**2 for _ ...
pieca's user avatar
  • 2,583
1 vote
1 answer
1k views

I want to stop the execution of the exec or eval commands if they take too long to complete. I know how to do it using multiprocessing but I was wondering if there's an easier solution. Any ideas?
yyy's user avatar
  • 920
1 vote
4 answers
992 views

I was wondering if there was away to redirect both the input and output of a python script to a file so that they were interlaced. Essentially say I have the following code: x = 1 print("hello, ...
gowerc's user avatar
  • 1,109
0 votes
1 answer
829 views

I am making a python IDE and I wanted to print the output of a file's code to the output text box. My current code doesnt work, it executes in the shell and the output is to the box is "None"...
user avatar
1 vote
1 answer
1k views

I'm making a program that generates code randomly in batches, and given an input, tests to see if that code generates the desired output. I'm wanting to make the batches of generated code pretty large,...
A. L. Strine's user avatar
2 votes
1 answer
631 views

I'm writing a Sublime Text plugin that provides multiple Python shells accessible via UNIX sockets. Each shell should act as a standalone REPL running on its own thread. (It is undesirable for these ...
Thom Smith's user avatar
  • 14.1k
0 votes
0 answers
298 views

I would like to change the standard output from a terminal to a string. I could use the instruction by Frédéric Hamidi in the web page: python: get the print output in an exec statement , and it works....
Anees's user avatar
  • 19
2 votes
2 answers
124 views

Good day! I'm trying to implement a module for testing knowledge. The user is given the task, he wrote the decision that is being sent and executed on the server. The question in the following. There ...
aphex's user avatar
  • 1,197

15 30 50 per page