Execute and create one python script from another
<p>Suppose, I have a python script <code>test1.py</code> , executing of <code>test1.py</code> will create a copy of that file, let's say <code>test2.py</code> . Now, I want to run <code>test1.py</code> in such a way that first it will create <code>test2.py</code> and then will execute <code>test2.py</code> . </p>

<p>This is my <code>test1.py</code> python script looks like, </p>

<pre><code>import io
import shutil
import os

shutil.copy2('test1.py', 'test2.py')
os.system("test2.py")
</code></pre>

<p>But out is saying <code>test2.py: not found</code></p>

<p>Run python with <code>test2.py</code> as it's first argument.</p>

<pre><code>os.system("python test2.py")
</code></pre>

<p>If you say what's your goal of this action. We can help you better.</p>

python