Society's Technical Debt and Software's Gutenberg Moment
I may be missing something obvious here, and I&#x27;m not a Python expert, but isn&#x27;t this &quot;get rid of all the emojis, except for one I like&quot; code snippet completely wrong (despite the article&#x27;s assertions that &quot;it works fine,&quot; &quot;the LLM used a neat hack,&quot; etc.)?<p>It seems to always just erase the file, because it declares `keep_emojis` to be a list of one element (`keep_emojis = [&#x27;¯\_(ツ)_&#x2F;¯&#x27;]`) and then goes USV-by-USV through the file to check if the encoded&#x2F;decoded coded char is &quot;in&quot; keep_emojis. And there&#x27;s basically no way that any single char can be. So the output is always empty.<p>If we wrote it like `keep_emojis = &#x27;¯\_(ツ)_&#x2F;¯&#x27;` instead, then it would be a little closer, but in that case the program ends up preserving <i>all</i> non-ASCII characters (including all emojis), because these characters become the empty string after emoji.encode(&#x27;ascii&#x27;, &#x27;ignore&#x27;) and are therefore always &quot;in&quot; the keep_emojis string, so they never get replaced.<p>The explanation also doesn&#x27;t make any sense, where it writes: &quot;In the above code, the assumption is made that any ASCII character that cannot be encoded using UTF-8 is an emoji.&quot;<p>That&#x27;s silly, because every ASCII character can be encoded in UTF-8. It also doesn&#x27;t correspond to what the code is doing -- what it&#x27;s really doing (I think) is testing for USVs that can&#x27;t be encoded in ASCII, but then throwing the char away no matter what.<p>And, of course, the vast majority of non-ASCII coded characters in Unicode are not emoji, so this is not really a good way to satisfy the user&#x27;s request. The roundtrip through ASCII seems like a bad idea -- if the user wants you to preserve <i>some</i> emojis while getting rid of <i>most</i> emojis, converting to ASCII (where there are <i>no</i> emojis) doesn&#x27;t seem like it will be helpful.<p>Of course it&#x27;s amazing that ChatGPT is already good enough to produce something close enough to fool venture capitalists into trusting it without trying the code, and these techniques will doubtless continue to improve.