Path: ...!eternal-september.org!feeder3.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail From: David Brown Newsgroups: comp.lang.c Subject: Re: Baby X is bor nagain Date: Wed, 19 Jun 2024 07:44:44 +0200 Organization: A noiseless patient Spider Lines: 38 Message-ID: References: <20240613002933.000075c5@yahoo.com> <20240613174354.00005498@yahoo.com> <20240617002924.597@kylheku.com> <20240618115650.00006e3f@yahoo.com> <20240618184026.000046e1@yahoo.com> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit Injection-Date: Wed, 19 Jun 2024 07:44:45 +0200 (CEST) Injection-Info: dont-email.me; posting-host="0e1bf1c39b81cc98682be3a9709bb4b3"; logging-data="1925546"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/7AlbA4EjBk+GTZBdD/xJNYny2rlrPRy4=" User-Agent: Mozilla Thunderbird Cancel-Lock: sha1:cXit57gpqEUZ5EdPU6e0QxjwSHI= Content-Language: en-GB In-Reply-To: Bytes: 3231 On 18/06/2024 18:39, Malcolm McLean wrote: > On 18/06/2024 16:40, Michael S wrote: >> On Tue, 18 Jun 2024 14:36:40 +0200 >> David Brown wrote: >> >>> >>> Of course if you don't know Python, it will be slower to write it in >>> Python! >>> >> >> I don't know Python well, but it does not meant that I don't know it at >> all. >> Few minutes ago I took a look into docs and it seems that situation with >> writing binary data files with predefined layout is better than what I >> was suspecting. They have something called "Buffer Protocol". It allows >> to specify layout in declarative manner, similarly to C struct or may >> be even to Ada's records with representation clause. >> However attempt to read the doc page further down proved that my >> suspicion about steepness of the learning curve was not wrong :( >> >> > My main experience of Python was that we had some resource files which > were icons, in matching light and dark themes. The light theme had > suffix _L followed by extension, and the dark themes had _D. And they > needed to be sorted alphabetically, except that _L should be placed > before _D. > And it didn't take long to get Python to sort the list alphabetically, > but there seemed no way in to the sort comparision function itself. And > I had to give up. > Python "sort" is a bit like C "qsort" (desperately trying to relate this to the group topicality) in that you can define your own comparison function, and use that for "sort". For simple comparison functions, people often use lambdas, for more complicated ones it's clearer to define a function with a name.