Warning: mysqli::__construct(): (HY000/1203): User howardkn already has more than 'max_user_connections' active connections in D:\Inetpub\vhosts\howardknight.net\al.howardknight.net\includes\artfuncs.php on line 21
Failed to connect to MySQL: (1203) User howardkn already has more than 'max_user_connections' active connectionsPath: ...!eternal-september.org!feeder3.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: vallor
Newsgroups: comp.os.linux.advocacy
Subject: Re: The Golly! of Python
Date: Wed, 17 Apr 2024 22:36:44 -0000 (UTC)
Organization: A noiseless patient Spider
Lines: 174
Message-ID:
References: <17c636a2d6477a17$13590$197378$802601b3@news.usenetexpress.com>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Injection-Date: Thu, 18 Apr 2024 00:36:44 +0200 (CEST)
Injection-Info: dont-email.me; posting-host="d2a93cb4de328dc802bf5fc44bf55bbe";
logging-data="1793978"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX19XtmS3byRsvFt1SS9VG3yi"
User-Agent: Pan/0.158 (Avdiivka; 6a11104 gitlab.gnome.org/GNOME/pan.git;
x86_64-pc-linux-gnu)
Cancel-Lock: sha1:2wckLk5a4N07+Zg2+S48o+1D2sk=
X-Face: \}2`P"_@pS86<'EM:'b.Ml}8IuMK"pV"?FReF$'c.S%u9 wrote in
:
> On 4/17/2024 2:26 PM, vallor wrote:
>> On Tue, 16 Apr 2024 09:10:26 -0400, DFS wrote in
>> :
>>
>>> 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?
>
>
> That was just my example. They're actually prefixed with the name of
> the newsgroup:
>
> comp.lang.c_551568
> comp.os.linux.advocacy_1239605
> etc.
>
> No extension.
>
> I use SuckMT for Windows to download them. Well, I try to, but it
> doesn't work too well. It always crashes after downloading around 4K
> message files.
>
>
>
>>> 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.
>
> ?
>
> You're not equipped to tsk my programming.
>
> That was an example for Feeb.
>
> The real thing:
> ------------------------------------------------------------------------
> msgdir = "D:/computer/dev/usenet/suckmt/posts/blocknews/" + sys.argv[1]
> + "/"
> msgfile = ''
> filearr = []
> for pfile in os.listdir(msgdir):
> if '_' in str(pfile):
> filearr.append(int(str(pfile).split('_')[1]))
> for articleID in sorted(filearr):
> msgfile = grpName + '_' + str(articleID)
> ....
> ------------------------------------------------------------------------
>
> In the first line, sys.argv[1] is my abbreviation for the newsgroup
> (cola, clc, cdma, etc) passed in from the command line. In the last
> line, grpName is the full name of the newsgroup. ID, abbreviation,
> group name and other info is in a db table.
>
>
>
>> BTW, have you ever used awk?
>
> A tiny bit.
>
>
> > (Also: see ls -v)
>
> Yeah, I know ls will list the files in the correct order. I couldn't
> make it happen using Windows dir, though.
>
> Windows File Explorer and thunar and Nemo showed them in the correct
> numerical order.
>
>
>>> -------------------------------------------------------------
>>> 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
>
>
> Please don't feed the "C Programmer Extraordinaire" any hints.
>
> Note: I do know how to write C to scan directories and list files and
> check file types and open and read the contents, etc.
>
>
>
>
> Feeb does not.
I looked at those, and had to do a double-take with the
second one.
Calling "file" is "cheating". ;) You can get crafty with
a lookup table and stat(2).
I mention this mainly because if Laughing Boy was
capable of reading your article, he'll surely launch
into a cackling fit that might brake his brane. (That
is...if he understood the program, which he probably wouldn't.)
(Regarding article lookups and such, I use a shell script that calls
openssl(1) s_client to connect, log in, and leaves me with
the NNTP prompt...a place at which Feeb would be lost.)
--
-v