That is quite nifty implementation of reverse HTML escaping. But in python that could be done with much less work:
import html
print(html.unescape(foo))
And the best part - you don't need to debug/update the (g)sub list every time you stumble upon new weird &whatever; too. And there are alot of those out there:
https://www.freeformatter.com/html-entities.html