wtfpython
wtfpython copied to clipboard
tiny wtfs
-
when one grapheme becomes two unicodepoints, thus len(string) is two:
len('g̈') 'U+', hex(ord('g̈'[0])) #returns the first -
despite added support for ordered dicts, the order does not matter when comparing:
{'a': 20, 'b': 2} == {'b':2, 'a':20} -
pow(4,-1, 3) == 4**-1 % 3
might be worth porting too: https://stackoverflow.com/questions/101268/hidden-features-of-python
Thanks for sharing these :)
The second one shows why using OrderedDict can still be useful in certain cases.
The third one actually throws an expception in Python 3.6, although it works fine with 3.8 or higher.