Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #85947
| References | <CANy1k1g+wU6VUifZpV5+DWendT2LqS-PhRA-KC5hmq2xQ_uy+A@mail.gmail.com> <CANy1k1gMgGnqNcgTwjcqfYH-QctZthv89uXcU8SV9Uk6Wji=4A@mail.gmail.com> |
|---|---|
| Date | 2015-02-19 22:21 -0700 |
| Subject | Re: What behavior would you expect? |
| From | Jason Friedman <jsf80238@gmail.com> |
| Newsgroups | comp.lang.python |
| Message-ID | <mailman.18910.1424409716.18130.python-list@python.org> (permalink) |
[Multipart message — attachments visible in raw view] - view raw
> 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.
Back to comp.lang.python | Previous | Next | Find similar | Unroll thread
Re: What behavior would you expect? Jason Friedman <jsf80238@gmail.com> - 2015-02-19 22:21 -0700
csiph-web