Python : Pass two values to funtion used in filter
<p>I made a filter function to filter out file types in a list of file names . </p>

<pre><code>&gt;&gt;&gt; l1
['180px-Cricketball.png', 'AgentVinod_450.jpg', 'Cricketball.bmp', 'Django-1.4', 'Django-1.4.tar.gz', 'Firefox Setup 11.0.exe', 'I-Will-Do-The-Talking-Tonight-(Muskurahat.Com).mp3', 'kahaani-.jpg', 'Never gonna leave this bed.mp3', 'Piya-Tu-Kaahe-Rootha-Re-(Muskurahat.Com).mp3', 'pygame-1.9.1release', 'pygame-1.9.1release.zip', 'pygame-1.9.2a0.win32-py2.7.msi', 'python-2.7.2.msi', 'python-3.1.2.msi', 'Resume.doc', 'selenium-2.20.0', 'selenium-2.20.0.tar.gz', 'sqlite-shell-win32-x86-3071100.zip', 'wxdesign_220a.exe', 'YTDSetup.exe']
&gt;&gt;&gt; def myfilt(subject):
    if re.search('.jpg',subject):
        return True


&gt;&gt;&gt; filter(myfilt,l1)
['AgentVinod_450.jpg', 'kahaani-.jpg']
</code></pre>

<p>This works fine.</p>

<p>Now suppose i want make this more flexible . I want to pass file type to the function . 
So i rewrite the function</p>

<pre><code>&gt;&gt;&gt; def myfilt(subject,filetype):
    if re.search(filetype,subject):
        return True
</code></pre>

<p>Now how do i pass the filetype through the filter function ?</p>

<p>I tried :</p>

<pre><code>&gt;&gt;&gt; filter(myfilt(l1,filetype),l1)

Traceback (most recent call last):
  File "&lt;pyshell#32&gt;", line 1, in &lt;module&gt;
    filter(myfilt(l1,filetype),l1)
  File "&lt;pyshell#28&gt;", line 2, in myfilt
    if re.search(filetype,subject):
  File "C:\Python27\lib\re.py", line 142, in search
    return _compile(pattern, flags).search(string)
TypeError: expected string or buffer
</code></pre>

<p>Nothings works. Any ideas? Thanks in advance</p>
