In June of 2022, Robert Evans (N2LO, but he will always be “Bob” in my mind)
posted a Python script to generate Morse code, or as he more accurately called
it, Morse-Vail code, because Alfred Vail
was the actual originator of the alphabetic code.
Here is a link to my version.