> I know I can use a variable in regular expressions. I want to use a
> regex to find something based on the beginning of the string. I am
> using yesterday's date to find all of my data from yesterday.
> Yesterday's date is 20070731, and assigned to the variable
> "yesterday_date". I want to loop thru a directory and find all of the
> yesterday's data ONLY IF the feature class has the date at the
> BEGINNING of the filename.

If i understood, you have directores with files named 20070731, 20070722 ...

So, what about:

import os
yesterday_date = '20070731'
list = os.listdir (dir)
for x in [x for x in list if x.startswith( yesterday_date ) ]:
    print x


Is  not a option?

[]'s
-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to