Best way to rewrite Popen

Jon Ribbens jon+usenet at unequivocal.co.uk
Tue May 19 17:28:52 EDT 2015


On 2015-05-19, Cecil Westerhof <Cecil at decebal.nl> wrote:
> It looks like that this does what I want (the dot is needed so that it
> also works with 2.7):
>     files = sorted(os.listdir('.'))
>     p = re.compile('actions-2015-05-[0-9][0-9].sql$')
>     current_month = [ file for file in files if p.match(file) ]

You could instead do (in Python 2 or 3):

  files = glob.glob("actions-2015-05-[0-9][0-9].sql")
  files.sort()



More information about the Python-list mailing list