What did I do wrong in my python script to get output?
<p>I think that's should work. I want to get output of this command 
"grep -l %s *.py" % tag for each tag, 
on created file with tag name.</p>

<pre><code>import os
import sys

results_dir = '/home/ks/one/work/tn/format-description 15852/results'
converters_dir = '/home/ks/one/work/cvr'
export_dir = '/home/ks/one/work/epr'
all_dirs = {'cvr':cvrs_dir, 
            'epr':eprs_dir}

tags = [tag.strip() for tag in open('new file').readlines()]
for coe, directory in all_dirs.items(): # coe - type of our file
    os.chdir(results_dir)
    for tag in tags:
        tag_file = open(coe + ' ' + tag, 'w')
        sys.stdout = tag_file
        os.chdir(directory)
        os.system("grep -l %s *.py" % tag)
        tag_file.close()
</code></pre>

<p>But all what I see when script is runned - it's output in my console.</p>
