Is there a similar or equivalent function in Python to the PHP function htmlspecialchars()? The closest thing I've found so far is htmlentitydefs.entitydefs().
If you are using django 1.0 then your template variables will already be encoded and ready for display. You also use the  safe operator {{ var|safe }} if you don't want it globally turned on.
Is there a Python equivalent to the PHP function htmlspecialchars()?