Deutsch English Français Italiano |
<uvp47u$1mntq$1@dont-email.me> View for Bookmarking (what is this?) Look up another Usenet article |
Path: ...!feeder1.cambriumusenet.nl!feed.tweak.nl!217.73.144.44.MISMATCH!feeder.ecngs.de!ecngs!feeder2.ecngs.de!feeds.phibee-telecom.net!2.eu.feeder.erje.net!feeder.erje.net!eternal-september.org!feeder3.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail From: vallor <vallor@cultnix.org> Newsgroups: comp.os.linux.advocacy Subject: Re: The Golly! of Python Date: Wed, 17 Apr 2024 18:26:06 -0000 (UTC) Organization: A noiseless patient Spider Lines: 93 Message-ID: <uvp47u$1mntq$1@dont-email.me> References: <17c636a2d6477a17$13590$197378$802601b3@news.usenetexpress.com> <uvltc2$v4b9$1@dont-email.me> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Injection-Date: Wed, 17 Apr 2024 20:26:06 +0200 (CEST) Injection-Info: dont-email.me; posting-host="1b21f3d259dad67e66b8c0a532591d94"; logging-data="1793978"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1861XQMa7eXdcKh0UfW8AcP" User-Agent: Pan/0.158 (Avdiivka; 6a11104 gitlab.gnome.org/GNOME/pan.git; x86_64-pc-linux-gnu) Cancel-Lock: sha1:70Z9WYiwdbfTeDDrt6UYLt1ZX4E= X-Face: \}2`P"_@pS86<'EM:'b.Ml}8IuMK"pV"?FReF$'c.S%u9<Q#U*4QO)$l81M`{Q/n XL'`91kd%N::LG:=*\35JS0prp\VJN^<s"b#bff@fA7]5lJA.jn,x_d%Md$,{.EZ Bytes: 3516 On Tue, 16 Apr 2024 09:10:26 -0400, DFS <nospam@dfs.com> wrote in <uvltc2$v4b9$1@dont-email.me>: > On 4/14/2024 1:46 PM, Lameass Larry Piet wrote: > >> Who would love python? Only a fucking asshole. > > Eric Raymond says: > > "I noticed (allowing for pauses needed to look up new features in > Programming Python) I was generating working code nearly as fast as I > could type." > > No wonder Gentoo depends so heavily on Python. > > Here's a list of some of the files in a directory: > > file_999 > file_1000 > file_998 > file_200 > file_2000 Why do you prefix them with "file_"? Why not name the files by article number, like other nntp software does? > > > How about some of your 'extraordinary' C to read the directory and list > those files in ascending order (because they need to be processed > sequentially by nbr)? > > > yeah, crickets, just like I knew > > > ------------------------------------------------------------- > import os > msgdir = "D:\\" > filearr = [] > for pfile in os.listdir(msgdir): > if '_' in pfile: > filearr.append(int(str(pfile).split('_')[1])) > for filenbr in sorted(filearr): > print("file_" + str(filenbr)) > print() > for filenbr in reversed(sorted(filearr)): > print("file_" + str(filenbr)) You assume they are prefixed with "file_" instead of, say, "foo_" -- but you print them as "file_xxx". Tsk, tsk, tsk. BTW, have you ever used awk? (Also: see ls -v) > ------------------------------------------------------------- > D:\>python temp.py > file_200 > file_998 > file_999 > file_1000 > file_2000 > > file_2000 > file_1000 > file_999 > file_998 > file_200 > ------------------------------------------------------------- > > It can also be done in fewer lines with the glob and regex modules, and > using list comprehension. > > By the way, I have a folder of 191K+ such files, and that code runs in: > > D:\>python temp.py > 0.13s to read 191490 files > First file is 730478 > Last file is 943773 > > > > Feeb severely pwned by his own ineptitude > C severely owned by python $ man 3 scandir and $ man 3 strverscmp -- -v