Liste des Groupes | Revenir à cl c |
On 18/06/2024 16:40, Michael S wrote: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.On Tue, 18 Jun 2024 14:36:40 +0200My 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.
David Brown <david.brown@hesbynett.no> 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 :(
>
>
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.
Les messages affichés proviennent d'usenet.