On 2015-01-02 21:21, Cameron Simpson wrote: > >def unlinkFiles(): > > dirname = "/path/to/dir" > > for f in os.listdir(dirname): > > if re.match("^unix*$", f): > > os.remove(os.path.join(dirname, f)) > > That is a very expensive way to check the filename in this > particular case. Consider: > > if f.startswith('unix'): > > instead of using a regular expression.
And worse, the given re would delete a file named "uni" which doesn't sound ANYTHING like what the OP wanted :-) -tkc -- https://mail.python.org/mailman/listinfo/python-list