How to convert all HTML tags and attributes in a string to lowercase in python?
I won't go so far as to say it's impossible, but this is an extremely tall order.  The reason is that an HTML parser will usually not attempt to preserve HTML-irrelevant characters like line endings, but anything other than an HTML parser will not be very good at telling what is or isn't a tag according to the strict definitions of the format.
If you really need to do this and do this well, I would look at dissecting an existing python HTML parser and modifying it to your needs.  This is a fairly advanced programming project.  It would be better to seriously consider why you need to do this and if this is strictly the right thing to do.
Edit: An additional problem is that it's not really possible to parse HTML without checking the validity of the HTML and either reforming it to be valid, or choking on invalid HTML.  So if you potentially have validity problems with your HTML, your result is undefined.  For instance, if the input includes a grossly invalid tag like <font="courier">, would that be considered an HTML tag for the purposes of this exercise, or just a string of parser-killing characters?  Likewise with a valid-looking tag in the wrong place in the document.
How can I convert all HTML tags and attributes in a string to lowercase in python? Nothing else should be changed, e.g. attribute values should not be changed, no indentation, line wrapping etc.
Sorry if it's too obvious :)