FInd files with .so extension

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • pradeep nair

    #1

    FInd files with .so extension

    HI,


    How do i find files with .so extension using python .

  • Steven D'Aprano

    #2
    Re: FInd files with .so extension

    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.sp litext)


    That should give you all the tools you need.



    --
    Steven D'Aprano

    Comment

    • kaens

      #3
      Re: FInd files with .so extension

      do YOU mean hit "reply to all" not "reply?"

      On 5/3/07, kaens <apatheticagnos tic@gmail.comwr ote:
      do you mean
      filelst.append( i)?
      >
      On 5/3/07, rishi pathak <mailmaverick66 6@gmail.comwrot e:
      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 <deepns7@gmail. comwrote:
      HI,
      >
      >
      How do i find files with .so extension using python .
      >
      --

      >


      --
      Regards--
      Rishi Pathak
      National PARAM Supercomputing Facility
      Center for Development of Advanced Computing(C-DAC)
      Pune University Campus,Ganesh Khind Road
      Pune-Maharastra
      --
      >

      Comment

      • pradeep nair

        #4
        Re: FInd files with .so extension

        On May 3, 11:27 am, kaens <apatheticagnos ...@gmail.comwr ote:
        do YOU mean hit "reply to all" not "reply?"
        >
        On 5/3/07, kaens <apatheticagnos ...@gmail.comwr ote:
        >
        do you mean
        filelst.append( i)?
        >
        On 5/3/07, rishi pathak <mailmaverick.. .@gmail.comwrot e:
        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 .
        >>
        --
        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
        ????

        Comment

        • mailme.gurpreet@gmail.com

          #5
          Re: FInd files with .so extension

          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(filepa ttern, base = '.'):
          regex = re.compile(file pattern)
          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

          Comment

          Working...