I found a simple Python 2 script to randomize (and repeat) a given sequence of emojis; however, none of the usual programs I use to write, test, or edit Python scripts were able to "elegantly" handle the emoji ZWJ sequences. Surprisingly, Pythonista for iOS was able to run the script (after updating the
print()) just fine.
Is there a Python 3 IDE on macOS that allows emoji ZWJ sequences to be treated as a single unit?
I tried the following programs. For each program, I tested with the emoji ZWJ sequence ??♂️ (Man Raising Hand: Medium Skin Tone).
- Sublime Text 3 (v3.2.2) encoded in UTF-8. It separated each component of the ZWJ sequence out. The editor "displays" the non-zero width characters, ? (U+1F64B), ? (U+1F3FD), and ♂️ (U+2642). Selecting the sequence shows 5 characters selected. (The ZWJ sequence is 5 characters long.)
- IDLE (v3.9), which froze when entering the test emoji ZWJ sequence.
- BBEdit (v13.5.1) encoded in UTF-8. It inconsistently separated the ZWJ sequence. The editor displays two characters, ?? (U+1F64B and U+1F3FD, I think?) and ♂️ (U+2642). Selecting the sequence shows 7 characters selected, but I can erase it by pressing delete 5 times.
- Terminal (v2.10), which is a build of zsh as of macOS Catalina (10.15). Inputting the emoji displays
<200d>part inverted in color. Unexpectedly, prepending the sequence with
??♂️, and I’m not sure what to take from that.
With full and grateful attribution to Cate Huston, this is the updated Python 3 script I was only able to run in Pythonista as described above.
import numpy import random emojilist = ['?','??','??','??','??','??'] repeated = numpy.repeat(emojilist, 10) random.shuffle(repeated) print(''.join(repeated))
Source: Python-3x Questions