2026-02-22 12:16 UTC
Replies (2)
-
@Gyroplast@furry.engineer 2026-02-22 12:42
@helloyanis @emmatyping String comparisons are a massive rabbit hole (heh), and depend entirely on the implementation of a programming language. In Python, "π¦" == 129418 == False, because you are testing equality of two objects of different types, a str and an int, which is always False as per spec. The comparison of two strings is done by comparing the numerical value of each character, one by one, and the numerical value of an emoji character is typically rather high, as opposed to an old-school ord("a") == 97. Comparison stops as soon as two compared characters are not equal, you don't need to look at the rest of the string: "z" > "aaa" == True. Strings (instances of str) compare lexicographically using the numerical Unicode code points (the result of the built-in function ord()) of their characters. 3 It doesn't matter to Python if it's a single character or a string, this was a C thing my addled brain regurgitated. Sowwy.
-
@Gyroplast@furry.engineer 2026-02-22 12:43
@helloyanis @emmatyping Bonus: printing an "ASCII"-table in 2026 is so much more colorful! $ python -c "print(ord('π¦'))" 129418 $ python -c "print(ord('πΊ'))" 128058 $ python -c "for i in range(ord('πΊ'), ord('πΊ') + 40): print(chr(i), end='')" πΊπ»πΌπ½πΎπΏππππππ πππππππππππππππππππππππππππ π‘