473,671 Members | 2,250 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

execfile return values

Hello all!
I've a little and no important question:
Suppose 2 scripts

##ex.py###
a=execfile('scr .py')
print "return value: ", a

##scr.py###
print "i'm scr.py"

Executing that, a takes None value.
Is there a way to handle the execution of the script ordered by the execfile
statement??

Another way that def & return in functions.

Thanks

Enrique (Madrid)


**AVISO DE CONFIDENCIALIDA D**
La información contenida en este mensaje y archivos es privada y confidencial estando dirigida solamente al destinatario. Si Ud. ha recibido esta información por error, por favor, proceda a su inmediata destrucción. Cualquier opinión o punto de vista contenido en este mensaje corresponde al remitente y necesariamente no representa la opinión del GRUPO XEROX.

Jul 18 '05 #1
2 5235
"Enrique" <en************ @xgs-spain.com> wrote in message
news:ma******** *************** ***********@pyt hon.org...
'''
##ex.py###
a=execfile('scr .py')
print "return value: ", a

##scr.py###
print "i'm scr.py"

Executing that, a takes None value.
'''
As documented in Lib Ref 2.1 Built-in Functions. If you have not read
the execfile doc, please do, or reread. If you have read (or reread),
tell us what part you do not understand.
Is there a way to handle the execution of the script ordered by the

execfile statement??

I do not understand 'handle the execution of'. What you are trying to
accomplish that did not happen?

Terry J. Reedy
Jul 18 '05 #2
Terry Reedy fed this fish to the penguins on Friday 03 October 2003
07:19 am:

I do not understand 'handle the execution of'. What you are trying to
accomplish that did not happen?
At a guess, I'd say he wants 'a' to have the contents of stdout ("i'm
scr.py").
-- =============== =============== =============== =============== == <
wl*****@ix.netc om.com | Wulfraed Dennis Lee Bieber KD6MOG <
wu******@dm.net | Bestiaria Support Staff <
=============== =============== =============== =============== == <
Bestiaria Home Page: http://www.beastie.dm.net/ <
Home Page: http://www.dm.net/~wulfraed/ <


Jul 18 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
17379
by: Jonathan | last post by:
I'm puzzled by Python's behavior when binding local variables which are introduced within exec() or execfile() statements. First, consider this simple Python program: # main.py def f() : x = 1 print "x:", x f()
1
3105
by: Bo Jacobsen | last post by:
I have a number of files compiled to bytecode using py_compile.compile(). The .pyc files can be invoked by python directly ($python file.pyc), but "loading" them by execfile just throws an exception ? Any suggestions Bo.
3
5623
by: v.vayer | last post by:
I need to execfile() from a function in order to set value for a global variable from inside the executed file. I know there are "globals" and "locals" optional arguments for execfile, but I just can't figure out how to use them correctly. Here is an example: Change.py ========= x = 555 Main.py
8
3317
by: R. Bernstein | last post by:
In doing the extension to the python debugger which I have here: http://sourceforge.net/project/showfiles.php?group_id=61395&package_id=175827 I came across one little thing that it would be nice to get done better. I notice on stack traces and tracebacks, an exec or execfile command appears as a stack entry -- probably as it should since it creates a new environment. However the frame information for exec or execfile looks like this:...
2
1784
by: Alex Popescu | last post by:
Hi all! not be present in Py3k. So, I am wondering what will be its replacement? Considering that most probably Py3k will keep eval and exec, this will still be possible (indeed requiring manual loading of the file string), so I would really appreciate some enlightning comments on this. Background: Basically this question is related to my learning process/working project. In this, I have the need to allow the final user to provide a...
1
2261
by: Fernando Perez | last post by:
Hi all, I'm finding the following behavior truly puzzling, but before I post a bug report on the site, I'd rather be corrected if I'm just missing somethin obvious. Consider the following trivial script: # Simple script that imports something from the stdlib from math import sin, pi
5
9383
by: George Sakkis | last post by:
I maintain a few configuration files in Python syntax (mainly nested dicts of ints and strings) and use execfile() to read them back to Python. This has been working great; it combines the convenience of pickle with the readability of Python. So far each configuration is contained in a single standalone file; different configurations are completely separate files. Now I'd like to factor out the commonalities of the different...
1
1547
by: moijes12 | last post by:
Hi i have 3 python files and i want to execute the files sequentially using the execfile command.Hence ,i have written the following program fileList = for fileName in fileList : execfile(fileName)
4
7076
by: TP | last post by:
Hello, I have a script that uses the "optparse" package to parse the command line. For example: $ script.py --help # displays help about script.py Is this possible to call such a script with execfile('') once in the Python interactive shell?
0
8917
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8821
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8598
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8670
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
7437
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6229
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5696
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
1
2812
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
2051
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.