regex - Python: function to identify all subfolders that match a pattern -


i have written following bit of code find subfolders matching pattern. not have way of checking function finding matches.

i want retrieve folders have name of form "19xx@60xx_npo" xx characters, possibly uppercase.

def findwrongencut(path):     pathlist = glob.glob("./%s/19*@60*_npo" %path)     print pathlist     print len(pathlist) 

does function above guarantee folders match "19xx@60xx_npo"

yes, match things not directories , names '19xxxxxx@60xxxxxxxx_npo'. if want match specific number of letters, use ? each character in glob. if want guarantee directories, throw trailing slash on glob expression:

pathlist = glob.glob("./%s/19??@60??_npo/" % path) 

Comments

Popular posts from this blog

html - How to style widget with post count different than without post count -

How to remove text and logo OR add Overflow on Android ActionBar using AppCompat on API 8? -

javascript - storing input from prompt in array and displaying the array -