[Tutor] Calling another script

tee chwee liong tcl76 at hotmail.com
Mon Apr 4 05:58:54 CEST 2011


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. 
 
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"
 
  		 	   		  
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/tutor/attachments/20110404/d52e3920/attachment.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: configuration.ini
Type: application/octet-stream
Size: 24 bytes
Desc: not available
URL: <http://mail.python.org/pipermail/tutor/attachments/20110404/d52e3920/attachment.obj>
-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: one.py
URL: <http://mail.python.org/pipermail/tutor/attachments/20110404/d52e3920/attachment.ksh>
-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: two.py
URL: <http://mail.python.org/pipermail/tutor/attachments/20110404/d52e3920/attachment-0001.ksh>
-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: three.py
URL: <http://mail.python.org/pipermail/tutor/attachments/20110404/d52e3920/attachment-0002.ksh>


More information about the Tutor mailing list