Outils pour utilisateurs

Outils du site


issue198:python

Greetings fellow beings. I’m back again with more Python stuff. As you might know, Python 3.12.0 was released on 2 October, 2023, bringing with it many new features and changes. One of the most welcome features is the more robust f-string parsing, that allows many things that would previously cause errors. I was originally planning on discussing the new release, but as I often do, I change plans. You can do an Internet search to find out more – until I get back to it. Then I thought that I would revisit SpeechRecognition in Python, since it was almost four years ago that I first wrote about it in Full Circle. There have been many advancements and changes, especially in the offline API routines, and more added. I had started working with a couple of the new API packages and was pretty pleased with the results. I was almost about to start the article when I heard from a friend with the handle of “Marvin”, from the PAGE Discord forum. He had a few questions, and the subject of a Python library named “Blessed” came up. I went to their website (https://github.com/jquast/blessed) and was really impressed with what I saw there. Think curses on steroids! One of the animated demos from a third party that uses Blessed caught my eye.

Bonjour à tous. Je suis de retour avec plus d'informations sur Python.

Comme vous le savez peut-être, Python 3.12.0 a été publié le 2 octobre 2023, apportant avec lui de nombreuses nouvelles fonctionnalités et des changements. L'une des fonctionnalités les plus appréciées est l'analyse plus robuste des chaînes de caractères f les f-strings), qui permet de nombreuses choses qui auraient auparavant provoqué des erreurs. J'avais initialement prévu de parler de la nouvelle version, mais comme je le fais souvent, j'ai changé d'avis. Vous pouvez faire une recherche sur Internet pour en savoir plus - jusqu'à ce que j'y revienne.

J'ai alors pensé revenir sur la reconnaissance de la parole en Python, puisque cela fait presque quatre ans que j'ai écrit pour la première fois à ce sujet dans le Full Circle. Il y a eu beaucoup d'avancées et de changements, en particulier dans les routines de l'API hors ligne, et d'autres ajouts ont été faits. J'ai commencé à travailler avec quelques-uns des nouveaux paquets d'API et j'étais assez satisfait des résultats.

J'étais sur le point de commencer l'article lorsque j'ai eu des nouvelles d'un ami dont le pseudonyme est « Marvin », sur le forum PAGE Discord. Il avait quelques questions, et le sujet d'une bibliothèque Python nommée « Blessed » a été soulevée. Je suis allé sur leur site Web (https://github.com/jquast/blessed) et j'ai été très impressionné par ce que j'y ai vu. Pensez à des malédictions sous stéroïdes ! L'une des démonstrations animées d'un tiers qui utilise Blessed a attiré mon attention.

I’ve always enjoyed crosswords and have wanted to try my hand at creating a crossword program for quite a while, but never took the time to get started. Something always comes up. The third party program is named “Cursewords” and uses Blessed as its “display engine”. Intrigued, I did a web search for Cursewords and found it pretty quickly (https://github.com/thisisparker/cursewords). Once you install it with pip, it will run in a terminal by using “cursewords puzzlename.puz” where puzzlename.puz is an Across Lite formatted crossword puzzle. Probably mostly known for the New York Times puzzles that can be downloaded and run in numerous programs including Cursewords. The big problem is that the Cursewords distribution does not come with any puzzle files at all. This led me to do another web search for puzzles in the .puz format. I found a number of sites that had some puzzles, but many required some sort of subscription. Luckily, I not only installed Cursewords, but also downloaded the zip file from the github website. So I dug into the source code and found that it includes a module named “puz.py”. This, it turns out, is the module that reads the .puz file. Another web search turned up a python library called (remarkably enough) “puzpy” (https://github.com/alexdej/puzpy). It is the same code as the puz.py file, written by the same author that wrote Cursewords. In addition, the puzpy library includes 14 test puzzles in the .puz format that covers different types of puzzles like standard, rebus, puzzles with shapes, puzzles with notes, and locked puzzles.

J'ai toujours aimé les mots croisés et je voulais essayer de créer un programme de mots croisés depuis un certain temps, mais je n'ai jamais pris le temps de commencer. Il y a toujours quelque chose qui arrive.

Le programme tiers s'appelle « Cursewords » et utilise Blessed comme « moteur d'affichage ». Intrigué, j'ai fait une recherche sur le Web pour Cursewords et je l'ai trouvé assez rapidement (https://github.com/thisisparker/cursewords). Une fois installé avec pip, il se lance dans un terminal en utilisant « cursewords puzzlename.puz » où puzzlename.puz est une grille de mots croisés au format Across Lite. Probablement plus connu pour les puzzles du New York Times qui peuvent être téléchargés et exécutés dans de nombreux programmes, y compris Cursewords.

Le gros problème est que la distribution de Cursewords ne contient aucun fichier de mots croisés. Cela m'a amené à faire une autre recherche sur Internet pour trouver des puzzles au format .puz. J'ai trouvé un certain nombre de sites qui proposaient des puzzles, mais beaucoup d'entre eux nécessitaient un quelconque abonnement. Heureusement, j'ai non seulement installé Cursewords, mais aussi téléchargé le fichier zip depuis le site github. J'ai donc creusé dans le code source et j'ai découvert qu'il incluait un module nommé « puz.py ». Il s'agit du module qui lit le fichier .puz. Une autre recherche sur le Web a permis de trouver une bibliothèque python appelée (de manière assez remarquable) « puzpy » (https://github.com/alexdej/puzpy). Il s'agit du même code que le fichier puz.py, écrit par le même auteur que Cursewords. En outre, la bibliothèque puzpy comprend 14 puzzles de test au format .puz qui couvrent différents types de puzzles comme des standards, des rébus, des puzzles avec des formes, des puzzles avec des notes et des puzzles verrouillés.

So, if you want to “hit the ground running'' and have some puzzle files for Cursewords, simply go to the puzpy github repository and download the distribution zip. If you are curious about the actual Across Lite file format, originally there was no documentation for the file format. However, thanks to some curious programmers, the format was reverse engineered and documented. The original documentation on this was put up on Google Code Archive (https://code.google.com/archive/p/puz/wikis/FileFormat.wiki) and since then has been reformatted and placed on github (https://gist.github.com/sliminality/dab21fa834eae0a70193c7cd69c356d5). If you are interested in writing applications that use the .puz format, I would suggest that you use the puzpy library to make your life easy and your development cycle much quicker. So that’s it for this month. Have a wonderful rest of the month. Until next time, as always; stay safe, healthy, positive and creative!

Donc, si vous voulez être opérationnel tout de suite et avoir des fichiers de puzzle pour Cursewords, allez simplement sur le dépôt github de puzpy et téléchargez le zip de la distribution.

Si vous êtes curieux de connaître le format du fichier Across Lite, sachez qu'il n'existait à l'origine aucune documentation sur ce format. Cependant, grâce à quelques programmeurs curieux, le format a été rétro-conçu et documenté. La documentation originale a été mise en ligne sur Google Code Archive (https://code.google.com/archive/p/puz/wikis/FileFormat.wiki) et a depuis été reformatée et placée sur github (https://gist.github.com/sliminality/dab21fa834eae0a70193c7cd69c356d5). Si vous souhaitez écrire des applications qui utilisent le format .puz, je vous suggère d'utiliser la bibliothèque puzpy pour vous faciliter la vie et accélérer votre cycle de développement.

C'est tout pour ce mois-ci. Je vous souhaite une excellente fin du mois.

Jusqu'à la prochaine fois, comme toujours, restez en sécurité, en bonne santé, positifs et créatifs !

issue198/python.txt · Dernière modification : 2023/10/31 17:55 de andre_domenech