By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
443,271 Members | 1,722 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 443,271 IT Pros & Developers. It's quick & easy.

FInd files with .so extension

P: n/a
HI,
How do i find files with .so extension using python .

May 3 '07 #1
Share this Question
Share on Google+
4 Replies


P: n/a
On Wed, 02 May 2007 21:58:41 -0700, pradeep nair wrote:
HI,
How do i find files with .so extension using python .


import os
help(os.listdir)
help(os.walk)
help(os.path.splitext)
That should give you all the tools you need.

--
Steven D'Aprano

May 3 '07 #2

P: n/a
do YOU mean hit "reply to all" not "reply?"

On 5/3/07, kaens <ap***************@gmail.comwrote:
do you mean
filelst.append(i)?

On 5/3/07, rishi pathak <ma*************@gmail.comwrote:
May be this would work
import os
grep="so"
dir="."
lst = os.listdir(dir)
filelst=[]
for i in lst:
if i.split(".")[len(i.split("."))-1] == grep:
lst.append(i)
print lst

On 2 May 2007 21:58:41 -0700, pradeep nair <de*****@gmail.comwrote:
HI,
>
>
How do i find files with .so extension using python .
>
--
http://mail.python.org/mailman/listinfo/python-list
>


--
Regards--
Rishi Pathak
National PARAM Supercomputing Facility
Center for Development of Advanced Computing(C-DAC)
Pune University Campus,Ganesh Khind Road
Pune-Maharastra
--
http://mail.python.org/mailman/listinfo/python-list
May 3 '07 #3

P: n/a
On May 3, 11:27 am, kaens <apatheticagnos...@gmail.comwrote:
do YOU mean hit "reply to all" not "reply?"

On 5/3/07, kaens <apatheticagnos...@gmail.comwrote:
do you mean
filelst.append(i)?
On 5/3/07, rishi pathak <mailmaverick...@gmail.comwrote:
May be this would work
import os
grep="so"
dir="."
lst = os.listdir(dir)
filelst=[]
for i in lst:
if i.split(".")[len(i.split("."))-1] == grep:
lst.append(i)
print lst
On 2 May 2007 21:58:41 -0700, pradeep nair <deep...@gmail.comwrote:
HI,
How do i find files with .so extension using python .
--
http://mail.python.org/mailman/listinfo/python-list
--
Regards--
Rishi Pathak
National PARAM Supercomputing Facility
Center for Development of Advanced Computing(C-DAC)
Pune University Campus,Ganesh Khind Road
Pune-Maharastra
--
>http://mail.python.org/mailman/listinfo/python-list
????

May 3 '07 #4

P: n/a
On May 3, 9:58 am, pradeep nair <deep...@gmail.comwrote:
HI,

How do i find files with .so extension using python .
Hi pradeep
This piece of code should help you
import os,re

def findfile(filepattern, base = '.'):
regex = re.compile(filepattern)
matches = []
for root,dirs,files in os.walk(base):
for f in files:
if regex.match(f):
matches.append(root + '/' + f)
return matches
HAPPY CODING

May 3 '07 #5

This discussion thread is closed

Replies have been disabled for this discussion.