What behavior would you expect?

Jason Friedman jsf80238 at gmail.com
Fri Feb 20 00:21:49 EST 2015


> def order_matching_files(a_path, a_glob="*"):
>     """Search a path for files whose names match a_glob
>     and return a list of the full path to such files, in descending
>     order of modification time. Ignore directories."""
>     previous_dir = os.getcwd()
>     os.chdir(a_path)
>     return_list = [os.path.join(a_path, x) for x in glob.glob(a_glob) if
> os.path.isfile(x)]
>     os.chdir(previous_dir)
>     return reversed(sorted(return_list, key=os.path.getmtime))
>

Oops, guess I'm not really returning a list, I'm returning an iterator.  I
should change either the comment or the return value.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-list/attachments/20150219/34ed45fc/attachment.html>


More information about the Python-list mailing list