How to execute python code from within a python method?
I'm writing a deployment engine for our code.
I plan to put a "dep开发者_运维百科loy.py" in each project directory and then decide what projects need to be deployed, having the "deploy.py" of each project execute his logic for proper deployment configuration.
How would you recommend doing this? I've been thinking about "executing" the python code in each deploy.py file from within the "deployment_engine.py" code (I got this idea from scons method of doing stuff).
Alternativly I would like to somehow "import" the code (note that under each project the file is named "deploy.py" so a simple import deploy.py
doesn't seem to do the job here)
Thank you,
Maxim.You can use the __import__
function to do dynamic imports.
精彩评论