Path: csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!eu.feeder.erje.net!newsfeed.xs4all.nl!newsfeed2a.news.xs4all.nl!xs4all!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail Return-Path: X-Original-To: python-list@python.org Delivered-To: python-list@mail.python.org X-Spam-Status: OK 0.040 X-Spam-Evidence: '*H*': 0.92; '*S*': 0.00; 'skip:[ 20': 0.04; 'subject:would': 0.07; 'def': 0.12; 'descending': 0.16; 'os.getcwd()': 0.16; 'modification': 0.16; 'ignore': 0.16; 'value.': 0.19; 'header:In-Reply-To:1': 0.27; 'message- id:@mail.gmail.com': 0.30; "i'm": 0.30; 'guess': 0.33; 'to:name :python-list': 0.33; 'comment': 0.34; 'received:google.com': 0.35; 'really': 0.36; 'returning': 0.36; 'subject:?': 0.36; 'should': 0.36; 'list': 0.37; 'skip:o 20': 0.38; 'to:addr:python-list': 0.38; 'files': 0.38; 'list,': 0.38; 'skip:& 20': 0.39; 'to:addr:python.org': 0.39; 'either': 0.39; 'full': 0.61; 'such': 0.63; 'subject:you': 0.87 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :content-type; bh=wwmY0DHg1My8GVbrCmF1+rb9amUlf6sqo05WB+StAik=; b=x9bpi9jDCC0n0PvY6kOQt1PVSiMubEdnNxTH7KR+f2LAsTOIPr4L8q4dhom4r0sEm9 9UFLKawBGTMZLmp7xOz7vHZjoDa5Z5SV5uKBvgRGmhm9Emeb3UoP9BuGubBT7GNdrfBI 4F02nvKnUXrFm3WS3HMw4IcKDegQDDGoO9p1i8DJX3m7bmoFP3i20OBZMvjTpaC89U6Q 9HSIQZZtQlucP7gBf23ELXnmkU0czkMBtt+7L0EGSaYDglG2zITYPGG3NmlYEfpo6UYj IEdBl4gHLzOwFd1nog8003xwvfQ+okWlvDL5tXWnb5Su2EFPIEFjiZrxEAg1sdjuhcGw UB5Q== MIME-Version: 1.0 X-Received: by 10.194.109.9 with SMTP id ho9mr14631043wjb.29.1424409709858; Thu, 19 Feb 2015 21:21:49 -0800 (PST) In-Reply-To: References: Date: Thu, 19 Feb 2015 22:21:49 -0700 Subject: Re: What behavior would you expect? From: Jason Friedman To: python-list Content-Type: multipart/alternative; boundary=047d7bf10a12c557c7050f7e3ab4 X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: General discussion list for the Python programming language List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Newsgroups: comp.lang.python Message-ID: Lines: 39 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1424409716 news.xs4all.nl 2857 [2001:888:2000:d::a6]:45996 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:85947 --047d7bf10a12c557c7050f7e3ab4 Content-Type: text/plain; charset=UTF-8 > 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. --047d7bf10a12c557c7050f7e3ab4 Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: quoted-printable

=
= def order_matching_files(a_path, a_glob=3D"*"):
=C2=A0=C2=A0= =C2=A0 """Search a path for files whose names match a_glob=C2=A0=C2=A0=C2=A0 and return a list of the full path to such files, in d= escending
=C2=A0=C2=A0=C2=A0 order of modification time. Ignore director= ies."""
=C2=A0=C2=A0=C2=A0 previous_dir =3D os.getcwd()=C2=A0=C2=A0=C2=A0 os.chdir(a_path)
=C2=A0=C2=A0=C2=A0 return_list =3D= [os.path.join(a_path, x) for x in glob.glob(a_glob) if os.path.isfile(x)]<= br>=C2=A0=C2=A0=C2=A0 os.chdir(previous_dir)
=C2=A0=C2=A0=C2=A0 return r= eversed(sorted(return_list, key=3Dos.path.getmtime))

Oops, guess I'm not re= ally returning a list, I'm returning an iterator.=C2=A0 I should change= either the comment or the return value.
--047d7bf10a12c557c7050f7e3ab4--