import re def processPattern(pattern, words5): count = 0 for word in words5: wordstr = word.decode() if re.search(pattern, wordstr): count += 1 print(str(count) + ': ' + wordstr + '\n', end='') from js import fetch import asyncio, os, sys, io, zipfile async def main(): # 5 letter word file from https://github.com/octokatherine/word-master/blob/main/src/data/words.js response = await fetch('https://willbraffitt.org/p/words5.txt') js_buffer = await response.arrayBuffer() py_buffer = js_buffer.to_py() # this is a memoryview words5 = py_buffer.tobytes().splitlines() # now we have a bytes object print(str(len(words5)) + ' words') while (pattern := input('')) != '': processPattern(pattern, words5) break asyncio.ensure_future(main())