Mixing python and bash shell's xargs command doubts
<pre><code>system : Centos 6.7 Lasted 
Shell : bash 
python : 2.6.6
</code></pre>

<p>It makes me very confused! example below:</p>

<p>5 files:</p>

<pre><code>a1111  a2222  b1111  b2222  t.py
</code></pre>

<p>t.py content:</p>

<pre><code>import sys

if __name__ == '__main__':
    a1 = sys.argv[1]
    print 'id(a1)=%s, len(a1)=%s, str(a1)=%s, type(a1)=%s' % (id(a1), len(a1), str(a1), type(a1))
</code></pre>

<p>do this like:</p>

<pre><code>ls | xargs -I{} echo $(python t.py '{}')
</code></pre>

<p>output:</p>

<pre><code>id(a1)=139821454683184, len(a1)=2, str(a1)=a1111, type(a1)=&lt;type 'str'&gt;
id(a1)=139821454683184, len(a1)=2, str(a1)=a2222, type(a1)=&lt;type 'str'&gt;
id(a1)=139821454683184, len(a1)=2, str(a1)=b1111, type(a1)=&lt;type 'str'&gt;
id(a1)=139821454683184, len(a1)=2, str(a1)=b2222, type(a1)=&lt;type 'str'&gt;
id(a1)=139821454683184, len(a1)=2, str(a1)=t.py, type(a1)=&lt;type 'str'&gt;
</code></pre>

<p>my question is why len(a1)=2, but str(a1)=a1111 ?， <strong>string length is obviously not equal to 2</strong>，</p>

<p>with no echo is ok, but it's not my question. I have use xargs -p option to print the cmd</p>

<pre><code>ls | xargs -I{} python t.py '{}'
</code></pre>