User Profile

Collapse

Profile Sidebar

Collapse
quailman
quailman
Last Activity: Jun 14 '07, 06:21 PM
Joined: Jun 14 '07
Location:
  •  
  • Time
  • Show
  • Source
Clear All
new posts

  • quailman
    replied to Question about listdir/regex/sort
    Wow! thanks you guys for the quick response. That took care of it, it's up and running like it should.

    Just for reference, here's what it looks like now.

    Code:
    import re,os
    
    files = os.listdir(os.getcwd())
    #files = ['blue13', 'red011', 'yellow', 'green1000']
    
    def numsort(c,d):
            def getnum(filename):
                    m = re.search(r'\d+',filename)
    ...
    See more | Go to post

    Leave a comment:


  • quailman
    started a topic Question about listdir/regex/sort

    Question about listdir/regex/sort

    Hi all. I'm kind of a python noobie, this is for my first usefull program, beyond just playing around with the language. Any help is appreciated. Here's the code that throws an error.

    Code:
    import re, os
    
    files = os.listdir(os.getcwd())
    #files = ['blue13', 'red011', 'yellow1', 'green1000']
    
    def getnum(filename): return float(re.findall(r'\d+',filename)[0])
    def numsort(a,b): return cmp(getnum(a),getnum(b))
    ...
    See more | Go to post
No activity results to display
Show More
Working...