Hi, On Fri, Jan 02, 2015 at 05:35:52AM -0600, Tim Chase wrote: > 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 :-)
yes, you're right - I've missed out a "." before the "*". :) thanks: a. -- I � UTF-8 -- https://mail.python.org/mailman/listinfo/python-list