Questions tagged [execfile]

execfile is a Python 2.x. built-in function that executes Python scripts from files.

88 questions
0
votes
0 answers

Does execfile() open and/or close file in Python?

I have three files: myfifo.py which is named-pipe, writer.py: path = "myfifo.py" fifo = open(path) for i in range(1,4): fifo.write( "print %d" % i ) fifo.close() and reader.py: path = "myfifo.py" execfile(path) If I execute the reader-file…
LRDPRDX
  • 631
  • 1
  • 11
  • 23
0
votes
0 answers

execfile runs in Idle but not when opened through taskmanager

I have 2 scripts, one is a Tkinter Gui which opens several programs and urls with buttons, and another which opens another Tkinter Gui with a drop down for specific file docs. I have created a Windows Task Manager task to run the first script when I…
JSwordy
  • 169
  • 1
  • 2
  • 13
0
votes
0 answers

Execute a PySide QtWidget using execfile

I want to create a small tool, that will read all the python tools in the folder, put them in a QListWidget and every time I double-click on one of the tools, it will run. ToolList.pyThat's the main window with the tools import sys import glob from…
Nick
  • 221
  • 2
  • 12
0
votes
1 answer

How to execute a python script from django management commands?

I'm trying execute a python script that is NOT inside my Django Project directory... for example this is my management class that I call with the command: I need to run this as ROOT because it needs access to the GPIO pins on my raspberry pi. (and…
user1920076
  • 103
  • 1
  • 1
  • 14
0
votes
0 answers

how to emulate linux command - "source filename -arg value" in python

I am trying to script the Linux instructions in python. I am not able to script the following in python. source /usr/home/modelling.rc -m model I tried subprocess.call(['/usr/home/modelling.rc', "-m", "model"]) ***E: You can't execute me directly,…
user3798648
  • 33
  • 1
  • 4
0
votes
2 answers

Alternative to python atexit module that works when called from other scripts

Using atexit.register(function) to register a function to be called when your python script exits is a common practice. The problem is that I identified a case when this fails in an ugly way: if your script it executed from another python script…
sorin
  • 161,544
  • 178
  • 535
  • 806
0
votes
1 answer

How to execfile an independent .py and continue on to next line of code in the original .py?

I have two python files: 'old.py' and 'new.py'. I would like to execute 'new.py' from 'old.py' using execfile("new.py"). However, rather than waiting for 'new.py' to completely finish its program before moving to the next line in 'old.py', I would…
Xander
  • 593
  • 1
  • 5
  • 19
0
votes
1 answer

Does PHP has python execfile like function?

Python has a function where we can execute a other python file and get methods from that file in vars. Below is the sample rough code to explain:= file1.py def method1(): print 'hello world' file2.py globals =…
Umakant Patil
  • 2,227
  • 6
  • 32
  • 58
0
votes
1 answer

Using execfile to go to a directory then run a variable

I am making a Python text-assistant. I am trying to use execfile() to run the questions. The file used to ask the question and the command files are in different directories so I cant use import (filename). My question is how can i run multiple…
0
votes
1 answer

Share plugin resources with implemented permission rules

I have multiple scripts that are exporting a same interface and they're executed using execfile() in insulated scope. The thing is, I want them to share some resources so that each new script doesn't have to load them again from the start, thus…
Dalen
  • 4,128
  • 1
  • 17
  • 35
0
votes
2 answers

Tkinter press a button to launch an animation .py file

Original question: I have a Tkinter button which upon pressing will execute a script.py file. #-*- coding: utf-8 -*- from Tkinter import * master = Tk() def callback(): execfile("script.py") b = Button(master, text="OK",…
0
votes
2 answers

Updating Python CLI while maintaining "python -c exectfile" interface

I have a number of scripts that reference a Python program via the: python -c "execfile('myfile.py'); readFunc(param='myParam', input='blahblah')" interface. What I'd like to do is conceptually simple: Develop a more modular system with a "main"…
user770901
  • 414
  • 1
  • 4
  • 15
0
votes
0 answers

python execfile; new window does not open up fully

I am having an issue with my execfile function. What i would like to do is open a new file upon the click of a menu item as shown underneath. The issue however, is that when the file opens, some of its contents opens up in the window where the…
zachary
  • 3
  • 6
0
votes
1 answer

Python: Access from within a lambda a name that's in the scope but not in the namespace

Consider the following code: aDict = {} execfile('file.py',globals(),aDict) aDict['func2']() # this calls func2 which in turn calls func1. But it fails And file.py contains this: def func1(): return 1 myVar = func1() # checking that func1…
GetFree
  • 40,278
  • 18
  • 77
  • 104
0
votes
0 answers

Python execfile() in daemon

I've found 'daemon.py' script by Sander Marechal and I want to use it to execute my simply test script which prints text. When I execute script without 'execfile()' it creates daemon-example.pid and daemon works but when I add 'execfile()' it…
mac
  • 23
  • 8