Outils pour utilisateurs

Outils du site


issue198:python

Ceci est une ancienne révision du document !


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.

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.

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!

issue198/python.1698501535.txt.gz · Dernière modification : 2023/10/28 15:58 de auntiee