从Python调用Python [英] Invoking Python from Python

查看:89
本文介绍了从Python调用Python的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,


我需要从另一个Python

程序中动态创建Python脚本,然后执行如此创建的脚本。我需要通过os.spawnl调用

Python还是有更好的方法?


谢谢,


-

John

Hi all,

I have a need to create a Python script on the fly from another Python
program and then execute the script so created. Do I need to invoke
Python through os.spawnl or is there a better way?

Thanks,

--
John

推荐答案

Am Tue,2005年11月8日08:10:25 -0800 schrieb John Henry:
Am Tue, 08 Nov 2005 08:10:25 -0800 schrieb John Henry:
大家好,

我需要从另一个Python程序中动态创建Python脚本然后执行这样创建的脚本。我是否需要通过os.spawnl调用Python?还是有更好的方法?
Hi all,

I have a need to create a Python script on the fly from another Python
program and then execute the script so created. Do I need to invoke
Python through os.spawnl or is there a better way?







用脚本创建源代码,不是一个好的解决方案。


一旦我不得不维护将其数据存储在lisp代码中的lisp代码,那么

(包括条件和循环)。这是一场噩梦。


请解释你想做什么,我们会找到更好的解决方案。


HTH,
Thomas


-

ThomasGüttler, http://www.thomas-guettler.de/

电子邮件:guettli(*)thomas-guettler + de

垃圾邮件捕手: ni *********** ***@thomas-guettler.de



Hi,

creating source code with a script, is no good solution.

Once I had to maintain lisp code which stored its data in lisp code, too
(incl. conditions and loops). It was a nightmare.

Please explain what you want to do, and we will find a better solution.

HTH,
Thomas

--
Thomas Güttler, http://www.thomas-guettler.de/
E-Mail: guettli (*) thomas-guettler + de
Spam Catcher: ni**************@thomas-guettler.de


文章< pa ************* ***************@thomas-guettler.de> ;,

Thomas Guettler< ni ************** @ thomas-guettler.de>写道:
In article <pa****************************@thomas-guettler.de>,
Thomas Guettler <ni**************@thomas-guettler.de> wrote:


John Henry写道:
John Henry wrote:
大家好,

我需要创建一个Python脚本从另一个Python
程序中飞出然后执行如此创建的脚本。我是否需要通过os.spawnl调用Python?还是有更好的方法?
Hi all,

I have a need to create a Python script on the fly from another Python
program and then execute the script so created. Do I need to invoke
Python through os.spawnl or is there a better way?




你能导入生成的脚本吗?这可能是一种方法,如果,例如,你正在生成一个模板。配置文件可能随后由人类编辑。



Could you import the generated script? This might be the way to go if,
e.g., you''re generating a "template" configuration file that might
subsequently be edited by a human being.


这篇关于从Python调用Python的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆