> >>> allowed = ['.txt', '.sql']
> >>> for path, dirs, files in os.walk("."):
> ... for f in files:
> ... if splitext(f)[1].lower() not in allowed: continue
Additionally, if you really do want to specify wildcards:
>>> allowed = ['*.txt', 'README*', '*.xml', '*.htm*']
>>> from
Tim Chase wrote:
> > 1) there seems to be an optional topdown flag. Is that passed to
> > os.walk(path, topdownFlag)
>
> Yes.
>
> > 2) I only want to process files that match *.txt for example... Does
> > that mean I need to parse the list of files for the .txt extention or
> > can I pass a wild
> 1) there seems to be an optional topdown flag. Is that passed to
> os.walk(path, topdownFlag)
Yes.
> 2) I only want to process files that match *.txt for example... Does
> that mean I need to parse the list of files for the .txt extention or
> can I pass a wildcard in the path parameter?
>>
Larry Bates wrote:
> KraftDiner wrote:
> > The os.walk function walks the operating systems directory tree.
> >
> > This seems to work, but I don't quite understand the tupple that is
> > returned...
> > Can someone explain please?
> >
> > for root, dirs, files in os.walk('/directory/'):
> > p
KraftDiner wrote:
> The os.walk function walks the operating systems directory tree.
>
> This seems to work, but I don't quite understand the tupple that is
> returned...
> Can someone explain please?
>
> for root, dirs, files in os.walk('/directory/'):
> print root
> # print dirs
> #
> The os.walk function walks the operating systems directory tree.
Yup.
> This seems to work, but I don't quite understand the tupple that is
> returned...
> Can someone explain please?
>
> for root, dirs, files in os.walk('/directory/'):
> print root
> # print dirs
> # print files
On Mon, 14 Aug 2006 07:44:39 -0700, KraftDiner wrote:
> The os.walk function walks the operating systems directory tree.
>
> This seems to work, but I don't quite understand the tupple that is
> returned...
> Can someone explain please?
>
> for root, dirs, files in os.walk('/directory/'):
>
The os.walk function walks the operating systems directory tree.
This seems to work, but I don't quite understand the tupple that is
returned...
Can someone explain please?
for root, dirs, files in os.walk('/directory/'):
print root
# print dirs
# print files
--
http://mail.