[Tutor] Calling another script

tee chwee liong tcl76 at hotmail.com
Mon Apr 4 07:10:50 CEST 2011


hi,
 
i opened a cmd DOS prompt to execute one.py. it works to execute codes from two.py and three.py. yes, you are fight it will not re-execute the module. 
is there a way to do it? i want after the python script finishes execution will return the control to the DOS prompt instead of leaving as >>>.
i tried putting sys.exit(). 
 
thanks
cltee
 


Date: Mon, 4 Apr 2011 00:29:19 -0400
From: bgailer at gmail.com
To: tutor at python.org
Subject: Re: [Tutor] Calling another script


On 4/3/2011 11:58 PM, tee chwee liong wrote: 


hi,
 
i want to read from a file which will indicate which operation to execute. so i'm using configparser module. i want one.py to read a configuration file and executes two.py and three.py. however, it only executes two.py and not three.py codes. pls help advise. 

I see no reason for the problem you report. I tested a brief version:
import two
import three
and it worked as expected.

The only reason I can think of for it not working is that you had already imported three.py. Importing again will NOT re-execute the module!


 
thanks
tcl
 
+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 
one.py:
import ConfigParser
config = ConfigParser.ConfigParser()
config.read("configuration.ini")
operation=config.get("config", "operation")
if int(operation)== 0:
    import two
    import three
else:
    print "Default"
 
two.py:
print "executing script number 2"
 
three.py:
print "executing script number 3"
 
 

_______________________________________________
Tutor maillist  -  Tutor at python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


-- 
Bob Gailer
919-636-4239
Chapel Hill NC
_______________________________________________ Tutor maillist - Tutor at python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor 		 	   		  
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/tutor/attachments/20110404/1925f836/attachment-0001.html>


More information about the Tutor mailing list