Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #108640

Re: How to get a directory list sorted by date?

Path csiph.com!fu-berlin.de!uni-berlin.de!not-for-mail
From Michael Selik <michael.selik@gmail.com>
Newsgroups comp.lang.python
Subject Re: How to get a directory list sorted by date?
Date Sun, 15 May 2016 15:50:38 +0000
Lines 30
Message-ID <mailman.33.1463327451.2226.python-list@python.org> (permalink)
References <vmpl0d-l9n.ln1@esprimo.zbmc.eu> <nh9gh6$ekb$1@ger.gmane.org> <20160515061511.7c62b0e1@bigbox.christie.dr> <nha1h2$r6s$1@ger.gmane.org> <CAGgTfkPfL2e419iMLP1012q10x-6dG3vaWDvaTFyPUyMrXh3Kw@mail.gmail.com>
Mime-Version 1.0
Content-Type text/plain; charset=UTF-8
X-Trace news.uni-berlin.de 9fycCsv8DJjcqSrh9V6r5wg+Z3JbtBfmCY3Vy88ls/LA==
Return-Path <michael.selik@gmail.com>
X-Original-To python-list@python.org
Delivered-To python-list@mail.python.org
X-Spam-Status OK 0.039
X-Spam-Evidence '*H*': 0.92; '*S*': 0.00; 'subject:How': 0.09; 'name)': 0.09; 'def': 0.13; 'received:io': 0.16; 'received:psf.io': 0.16; 'sorted()': 0.16; 'wrote:': 0.16; '&gt;': 0.18; 'email addr:gmail.com&gt;': 0.18; 'to:2**1': 0.21; 'tim': 0.24; 'header:In-Reply-To:1': 0.24; "doesn't": 0.26; 'subject:list': 0.26; 'message-id:@mail.gmail.com': 0.27; 'sequence': 0.27; 'correct': 0.28; 'idea': 0.28; 'chase': 0.29; '15,': 0.30; 'skip:_ 10': 0.32; 'received:google.com': 0.35; 'next': 0.35; 'path': 0.35; 'item': 0.35; 'received:209.85': 0.36; 'to:addr:python-list': 0.36; 'subject:?': 0.36; 'subject:: ': 0.37; 'received:209': 0.38; 'skip:o 20': 0.38; 'rather': 0.39; 'skip:e 20': 0.39; 'to:addr:python.org': 0.40; 'subject:get': 0.81; 'otten': 0.84; 'sort.': 0.84; 'edwards': 0.91
DKIM-Signature v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:references:in-reply-to:from:date:message-id:subject:to; bh=LWJamK44QHZzwizz7O5d/G7OD6D9hvBITrRcAFgWh/8=; b=E6Cgs0nDi7vQhjFSwimMentr8Nt4k0Vy5Xmi4SpA7els5putVEwCNibN2gAgVaH/Uk 7fk4q+PEZcS28ddrzFkCNRzNXssafNfx2kAwlYSJ7LXasRwlvDZq7mtqaVKvOttjEBis 8XWkHacUy5jIX71ikFQ4FSRBh/awq6xgx4fKCRQfqe+ADRMhh/Bs3HVK1FfFsrN8G3AM 37xuWLLciroPSQoRxex0VcAYQOX97TLoKjJzFPTgco9gkW7t6X3tMW04fFyFD8rJeQ5U X8sudBRlc/2st4KOJm5SkR3218TicUGLK3w/UnXtz50NNnWCAnc/kHjlk0NSYca9x+t2 o5tA==
X-Google-DKIM-Signature v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to; bh=LWJamK44QHZzwizz7O5d/G7OD6D9hvBITrRcAFgWh/8=; b=Q3GKVEvof4dyG8D5ovdOqXuy5UNRl/ZyXlTNyCstLFWUTykjXVmfvU0m3RqymmGeD5 L8Q1UoQ1/7cUKXDkRVnTZq1u0xsKLWHxTA6jegSzh1ve4c37+kjUCgTltTOG+ferqREw RJFZ4TkxpfVPyo4Kj3QKNdEU+YKpOxEQoETwGhkX+g8cZ/e6s3RBuNRcM78Anb/XzCkp MB/bMjihmbI0uJGISKRpAHoJGckTdV7yQJ4ZX641Lr9HpSHVxdsh1yecInliI9x5oY+0 6mX9qhYwCGjuP6hbaQWL42OGfQ6ANNHs0CAeASnmph/lPNa42UIXILX8NsaKST278Ppy AJFA==
X-Gm-Message-State AOPr4FWnFAFZmnAxYlrzYhnvx4IorPBjxqJzafzsSmtaiAX3wjYYdiuyG/ii7j2DVpnLgew09Og+9jvzCTZmfw==
X-Received by 10.140.92.65 with SMTP id a59mr24183267qge.93.1463327448363; Sun, 15 May 2016 08:50:48 -0700 (PDT)
In-Reply-To <nha1h2$r6s$1@ger.gmane.org>
X-Content-Filtered-By Mailman/MimeDel 2.1.22
X-BeenThere python-list@python.org
X-Mailman-Version 2.1.22
Precedence list
List-Id General discussion list for the Python programming language <python-list.python.org>
List-Unsubscribe <https://mail.python.org/mailman/options/python-list>, <mailto:python-list-request@python.org?subject=unsubscribe>
List-Archive <http://mail.python.org/pipermail/python-list/>
List-Post <mailto:python-list@python.org>
List-Help <mailto:python-list-request@python.org?subject=help>
List-Subscribe <https://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe>
X-Mailman-Original-Message-ID <CAGgTfkPfL2e419iMLP1012q10x-6dG3vaWDvaTFyPUyMrXh3Kw@mail.gmail.com>
X-Mailman-Original-References <vmpl0d-l9n.ln1@esprimo.zbmc.eu> <nh9gh6$ekb$1@ger.gmane.org> <20160515061511.7c62b0e1@bigbox.christie.dr> <nha1h2$r6s$1@ger.gmane.org>
Xref csiph.com comp.lang.python:108640

Show key headers only | View raw


On Sun, May 15, 2016, 10:37 AM Grant Edwards <grant.b.edwards@gmail.com>
wrote:

> On 2016-05-15, Tim Chase <python.list@tim.thechases.com> wrote:
> > On 2016-05-15 11:46, Peter Otten wrote:
> >> def sorted_dir(folder):
> >>     def getmtime(name):
> >>         path = os.path.join(folder, name)
> >>         return os.path.getmtime(path)
> >>
> >>     return sorted(os.listdir(folder), key=getmtime, reverse=True)
> >>
> >> The same idea will work with pathlib and os.scandir():
> >>
> >> def _getmtime(entry):
> >>     return entry.stat().st_mtime
> >>
> >> def sd_sorted_dir(folder):
> >>     return sorted(os.scandir(folder), key=_getmtime, reverse=True)
> >
> > unless sorted() returns a lazy sorter,
>
> What's a lazy sorter?
>

One that doesn't calculate the next item in the sequence until you ask for
it. It's impossible unless you don't mind an approximation rather than
correct sort.

>

Back to comp.lang.python | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

How to get a directory list sorted by date? cl@isbd.net - 2016-05-15 09:47 +0100
  Re: How to get a directory list sorted by date? Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2016-05-15 20:48 +1000
  Re: How to get a directory list sorted by date? Michael Selik <michael.selik@gmail.com> - 2016-05-15 15:50 +0000
  Re: How to get a directory list sorted by date? Grant Edwards <grant.b.edwards@gmail.com> - 2016-05-15 16:00 +0000
  Re: How to get a directory list sorted by date? Tim Chase <python.list@tim.thechases.com> - 2016-05-15 13:12 -0500
    Re: How to get a directory list sorted by date? cl@isbd.net - 2016-05-15 21:23 +0100
  Re: How to get a directory list sorted by date? Chris Angelico <rosuav@gmail.com> - 2016-05-16 07:52 +1000
  Re: How to get a directory list sorted by date? Random832 <random832@fastmail.com> - 2016-05-16 12:40 -0400

csiph-web