pass python lists tp methods
<p>I want to read a file and create a list from one of its columns by split() method and pass on this list to another method. Can someone explain what is the most pythonic way to achieve that ??</p>

<pre><code>def t(fname):
     k = []
     with open(fname, 'rU') as tx:
         for line in tx:
             lin = line.split()
             k.append(lin[1])
             res = anno(k)
             for id in res.items():
                  if i &gt; 0.05:
                      print(i)
</code></pre>

<p>I want to pass elements of 'k' as one list to anno() method. But in this way, I have number of lists but not one (required). </p>

<p>I think you just did a mistake with the nesting. You have to call <code>anno()</code> after you've build the list, outside the for loop.</p>

<pre><code>def t(fname):
    k = []
    for line in open('fname'):
        k.append(line.split()[1])
    res = anno(k)
</code></pre>

python list methods