looking for a simple way to load a program from another python program..

AlbaClause you at cogeco.ca
Mon Aug 14 11:43:45 EDT 2006


Eric_Dexter at msn.com wrote:

>     I was looking for a simple way to load a simple python program from
> another python program.
> 
> I tried
> 
> os.system(cabel)
> 
> The file name is cabel.py a csound instrument editor..
> 
> The error I am getting is
> 
> Traceback (most recent call last):
>   File "C:\Python24\Lib\site-packages\boa-constructor\test of
> snake\Frame1.py", line 212, in OnCabelItems0Menu
>     os.system(cabel)
> NameError: global name 'cabel' is not defined
> Localisation of messages is disabled, using default language.
> time resolution is 279.365 ns
> 
> This is with cabel in the current directory.  I have managed to use
> import to run it but it will only do it once.  I may be able to use the
> exec commands but I don't want to exit the program I am using only to
> run other programs and then exit.  I would also perfer that cabel is in
> it's own directory.
> 
> thanks in advance for any help
> 
> http://www.stormpages.com/edexter/csound.html

I am new to Python coding myself, but I've found that the easiest way to
start another script from within a script, is to use the
execfile('filename.py') command.

There may be better ways of loading other Python scripts -- better ways that
I'm not yet aware of -- but execfile() works for me.


-- 
--
There are several things that I will never be:
  *  I will never be attracted to females.
  *  I will never enjoy the company of others.
Exactly how these realities bode for my enemy, is not of my concern.




More information about the Python-list mailing list